/* デザイントークン*/

:root {
  /* Colors */
  --color-bg: #F7F8FA;
  --color-card-bg: #FFFFFF;
  --color-border: #E5E7EB;
  --color-text-main: #1F2937;
  --color-text-sub: #6B7280;
  --color-primary: #2563EB;
  --color-success: #059669;
  --color-danger: #EF4444;

  /* Terrain colors */
  --terrain-red: #D9534F;
  --terrain-orange: #F0AD4E;
  --terrain-yellow: #F7E463;
  --terrain-green: #5CB85C;
  --terrain-deep-green: #3D8B3D;

  /* Typography */
  --font-family-base: "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-title: 16px;
  --font-size-body: 14px;
  --font-size-label: 12px;
  --font-size-metric: 20px;

  /* Radius & Shadow */
  --radius-card: 12px;
  --shadow-card: 0 4px 12px rgba(15, 23, 42, 0.08);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
}

/*画面全体レイアウト*/
body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  font-family: var(--font-family-base);
  color: var(--color-text-main);
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

/* 上部ナビ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: #FFFFFF;
  border-bottom: 1px solid var(--color-border);
}

/* カードタブ（横スクロール） */
.card-tabs {
  display: flex;
  overflow-x: auto;
  padding: var(--space-sm) var(--space-lg);
  gap: var(--space-sm);
  background: #FFFFFF;
}

.card-tab {
  padding: var(--space-xs) var(--space-md);
  border-radius: 999px;
  border: 1px solid var(--color-border);
  font-size: var(--font-size-label);
  white-space: nowrap;
  color: var(--color-text-sub);
  background: #FFFFFF;
}

.card-tab--active {
  border-color: var(--color-primary);
  color: var(--color-primary);
  font-weight: 600;
}

.card-tab--add {
  color: var(--color-primary);
}

/* メインコンテンツ（カード詳細） */
.app-main {
  flex: none;
  flex-shrink: 0;
  padding: var(--space-md) ;
  overflow-y: visible;
  min-height: 0;
}

/*比較カード*/
.card {
  background: var(--color-card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  position: relative;
}

/* タイトル行 */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: var(--font-size-title);
  font-weight: 700;
  line-height: 1.4;
}

.card-title span.type {
  color: var(--color-text-main);
}

.card-title span.loan {
  color: var(--color-primary);
}

.card-title span.fcf {
  color: var(--color-success);
}

.card-title span.land {
  color: var(--color-text-sub);
}

/* アイコンボタン（編集・削除） */
.card-actions {
  display: flex;
  gap: var(--space-xs);
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-button--danger {
  background: #FEE2E2;
  color: var(--color-danger);
}

/* ============================
   設定モーダル（共通）
============================ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.4);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal-content {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  width: 320px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.expert-only { display: none; }
.modal-content.expert .expert-only { display: block; }

.modal-content label {
  display: block;
  margin-top: 10px;
  font-size: 14px;
}

.modal-content input {
  width: 100%;
  padding: 6px;
  margin-top: 4px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.modal-content button {
  margin-top: 15px;
  padding: 8px 12px;
}

.expert-only {
  display: none;
}

.modal-content.expert .expert-only {
  display: block;
}

/* ============================
   専門家モード（緑系）
============================ */
.modal-content.expert {
  background: #F3FBF4; /* 薄い緑 */
  border-left: 6px solid var(--color-success); /* 深い緑のアクセント */
}

.modal-content.expert h2 {
  color: var(--color-success);
}

/* ============================
   ミニカード（一覧用）
============================ */
.mini-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 8px;
  gap: 4px;
  margin-bottom: var(--space-md);
  flex: none;

  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 160px;
  min-width: 160px;
  height: 360px;
  box-sizing: border-box;
  position: relative;
}

.mini-card .delete-button {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #FEE2E2;
  color: #EF4444;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
}

/* MiniMatrix 全体のサイズ（横4枚レイアウト用） */
.mini-terrain-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  margin-bottom: 4px;
  flex: none;
}

.mini-terrain-cell {
  width: 20px;
  height: 20px;
  border-radius: 2px;
}

/* ================================
   Diagnosis Section (Score + Comments)
   ================================ */

#diagnosis-section {
  margin-top: 40px;
  padding: 20px;
}

.score-box {
  width: 100%;
  max-width: 480px;
  margin: 0 auto 40px auto;
  padding: 24px 20px;
  border-radius: 12px;
  text-align: center;
  color: #fff;
  font-weight: bold;
}

.score-number {
  font-size: 64px;
  line-height: 1.1;
  margin-bottom: 8px;
}

.score-summary {
  font-size: 20px;
  line-height: 1.4;
}

/* 色分け（buildDiagnosis.js の scoreColor と連動） */
.score-box.green  { background-color: #4CAF50; }
.score-box.blue   { background-color: #2196F3; }
.score-box.yellow { background-color: #FFC107; color: #333; }
.score-box.orange { background-color: #FF9800; }
.score-box.red    { background-color: #F44336; }

/* セクションタイトル */
#diagnosis-details h3 {
  margin-top: 32px;
  margin-bottom: 12px;
  font-size: 22px;
  border-left: 4px solid #1976d2;
  padding-left: 10px;
}

/* 段落（26文字前後で <br> 改行） */
#diagnosis-details p {
  font-size: 16px;
  line-height: 1.8;
  margin-bottom: 20px;
}

/* ================================
   MiniCard Axis + Layout
================================ */

.mini-card-title {
  font-size: 14px;
  font-weight: bold;
  margin: 0 28px 6px 0;
  min-height: 3.2em; /* 2行分の高さを確保 */
  line-height: 1.6em;
  display: block;
}

.mini-matrix-wrapper {
  display: grid;
  grid-template-columns: 24px auto; /* 左：縦軸、右：マトリクス */
  column-gap: 4px;
}

.mini-card-matrix-row {
  display: flex;
  align-items: center;
}

.mini-card-yaxis {
  display: grid;
  grid-template-rows: repeat(6,1fr);
  justify-content: space-between;
  width: 28px;
  margin-right: 0;
  font-size: 12px;
  text-align: right;
}

.mini-card-stability {
  margin-top: 8px;
  font-size: 14px;
}

/* ============================
   一覧モード（mini だけ表示）
============================ */
#cardContainer.list-only {
  display: block;
  width: 100%;
}

#cardContainer.list-only #miniCardContainer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

#cardContainer.list-only #cardDetail {
  display: none;
}


/* ============================
   詳細モード（detail だけ表示）
============================ */
#cardContainer.detail-only {
  display: block;
  width: 100%;
}

#cardContainer.detail-only #miniCardContainer {
  display: none;
}

#cardContainer.detail-only #cardDetail {
  display: block;
  width: 100%;
}

/* 通常：flex レイアウト */
#cardContainer {
  display: flex;
  flex-direction: row;
  gap: var(--space-md);
}

#miniCardContainer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  width: 100%;
}

#cardDetail {
  width: 100%;
}

.detail-card-list {
  width: 100%;
}

.mini-card-stability {
  margin-top: 0;
  margin-bottom: 0; /* ← これが決定打 */
}

.mode-switch {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
}

.mode-button {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid #ccc;
  background: #f5f5f5;
  font-size: 12px;
}

.mode-button.active {
  background: #2b6cb0;
  color: #fff;
  border-color: #2b6cb0;
}

.normal-mode-inner {
  max-width: 720px;
  margin: 0 auto;
}

.step-block {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.step-block h2 {
  font-size: 14px;
  margin-bottom: 8px;
}

.step-block h3 {
  font-size: 13px;
  margin: 8px 0 4px;
}

.radio-group label {
  margin-right: 12px;
  font-size: 12px;
}

.button-secondary {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 16px;
  border: 1px solid #ccc;
  background: #f5f5f5;
}

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #333;
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  opacity: 0.9;
  z-index: 9999;
  font-size: 14px;
}

.event-list {
  margin: 10px 0 20px 0;
  padding-left: 10px;
  border-left: 3px solid #ddd;
}

.event-item {
  margin-bottom: 8px;
  font-size: 14px;
}

/* イベント一覧（通常モード） */
.event-list {
  margin: 6px 0 14px 0;
  padding-left: 8px;
  border-left: 2px solid #e5e7eb; /* 薄いグレー */
}

.event-item {
  font-size: 13px;
  line-height: 1.35;
  margin-bottom: 4px;
  color: #374151; /* 少し濃いグレーで視認性UP */
  white-space: nowrap; /* 改行させない（一覧性UP） */
  padding-left: 2px;
  letter-spacing: -0.2px;
}

.diag-section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 12px 0 4px 0;
  color: #1f2937;
}

.diag-section-body {
  font-size: 13px;
  line-height: 1.45;
  margin-left: 6px;
  color: #374151;
}