/* 後悔3Dマップ — 明るく軽やかなトーン（白 / 淡いブルー / グリーン / オレンジ） */
:root {
  --bg: #f2f7fb;
  --panel: #ffffff;
  --ink: #21323f;
  --ink-soft: #5b7183;
  --line: #e2ecf3;
  --blue: #4aa8ff;
  --blue-deep: #2b7fd4;
  --green: #35c48b;
  --orange: #ff9f43;
  --purple: #a06bff;
  --gold: #ffc44d;
  --shadow: 0 8px 24px rgba(43, 88, 130, 0.10);
  --radius: 14px;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---- 上部バー ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(100deg, #ffffff 0%, #eaf4ff 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 30px; filter: drop-shadow(0 2px 3px rgba(74,168,255,.35)); }
.brand-text h1 { margin: 0; font-size: 20px; letter-spacing: .02em; }
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btn {
  border: 1px solid transparent; background: transparent; color: var(--ink-soft);
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 14px;
  transition: all .15s ease;
}
.nav-btn:hover { background: #eaf3fc; color: var(--blue-deep); }
.nav-btn.is-active { background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(74,168,255,.4); }

/* ---- 3カラムレイアウト ---- */
.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 260px 1fr 340px;
  gap: 0;
}
.panel {
  background: var(--panel);
  display: flex; flex-direction: column;
  min-height: 0;
}
.panel-left { border-right: 1px solid var(--line); padding: 16px; }
.panel-right { border-left: 1px solid var(--line); }
.panel-head { margin-bottom: 10px; }
.panel-head h2 { margin: 0; font-size: 15px; }
.hint { font-size: 11px; color: var(--ink-soft); }

/* イベント一覧 */
.event-list { list-style: none; margin: 0 0 12px; padding: 0; overflow-y: auto; flex: 1; }
.event-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  transition: all .15s ease; background: #fbfdff;
}
.event-item:hover { border-color: var(--blue); transform: translateX(3px); }
.event-item.is-selected { border-color: var(--blue); background: #eaf4ff; box-shadow: var(--shadow); }
.event-item .age { font-weight: 700; font-size: 15px; min-width: 42px; }
.event-item .meta .title { font-size: 14px; }
.event-item .meta .cat { font-size: 11px; color: var(--ink-soft); }
.event-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.era-past { background: #90a4b4; }
.era-present { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.era-future { background: var(--green); }
.badge-branch { font-size: 10px; color: var(--orange); border: 1px solid var(--orange); border-radius: 6px; padding: 1px 5px; margin-left: auto; }

/* ---- 中央ステージ ---- */
.stage { position: relative; min-height: 0; background: #dcecfa; overflow: hidden; }
#scene-canvas { display: block; width: 100%; height: 100%; }
.stage-guide {
  position: absolute; left: 14px; top: 12px; display: flex; gap: 12px; flex-wrap: wrap;
  background: rgba(255,255,255,.78); backdrop-filter: blur(4px);
  padding: 7px 12px; border-radius: 999px; font-size: 12px; color: var(--ink-soft);
  box-shadow: var(--shadow); pointer-events: none;
}
.hover-tip {
  position: absolute; pointer-events: none; z-index: 8;
  background: rgba(33,50,63,.92); color: #fff; padding: 6px 10px; border-radius: 8px;
  font-size: 12px; transform: translate(-50%, -130%); white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
}
.hover-tip::after {
  content: ''; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: rgba(33,50,63,.92);
}
.flow-strip {
  position: absolute; right: 14px; bottom: 14px;
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(4px);
  padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow); font-size: 12px;
}
.flow-strip i { color: var(--ink-soft); font-style: normal; }
.flow-step { color: var(--ink-soft); padding: 2px 8px; border-radius: 999px; }
.flow-step.is-now { background: var(--gold); color: #5a4300; font-weight: 700; }
.flow-step.pulse { animation: pulse 1.2s ease; }
@keyframes pulse { 0%{transform:scale(1)} 40%{transform:scale(1.25)} 100%{transform:scale(1)} }
.loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #dcecfa; color: var(--blue-deep); font-size: 15px; z-index: 12;
  transition: opacity .5s ease;
}
.loading.hide { opacity: 0; pointer-events: none; }

/* ---- 右パネル詳細 ---- */
.panel-scroll { overflow-y: auto; padding: 16px; flex: 1; }
.detail-title { margin: 0 0 4px; font-size: 17px; }
.detail-sub { color: var(--ink-soft); font-size: 12px; margin: 0 0 14px; }
.card {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
  background: #fbfdff;
}
.card h3 { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.card p { margin: 0; font-size: 14px; line-height: 1.6; }
.empty-state { color: var(--ink-soft); font-size: 14px; text-align: center; padding: 40px 12px; line-height: 1.8; }

/* メトリクスバー */
.metric { margin-bottom: 8px; }
.metric-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.metric-bar { height: 8px; background: #e9f1f8; border-radius: 999px; overflow: hidden; }
.metric-fill { height: 100%; border-radius: 999px; background: var(--blue); transition: width .6s ease; }

/* スコアリング */
.score-row { display: flex; gap: 10px; }
.score-box { flex: 1; text-align: center; border-radius: 12px; padding: 10px; color: #fff; }
.score-box .n { font-size: 26px; font-weight: 800; line-height: 1; }
.score-box .l { font-size: 11px; opacity: .95; }
.score-regret { background: linear-gradient(135deg, #ff8a5b, var(--orange)); }
.score-change { background: linear-gradient(135deg, #35c48b, #24a7c9); }

/* 分岐チップ / ボタン */
.branch-grid { display: grid; gap: 10px; }
.branch-card { border-radius: 12px; padding: 12px; color: #fff; cursor: pointer; transition: transform .15s ease; }
.branch-card:hover { transform: translateY(-2px); }
.branch-card h4 { margin: 0 0 8px; font-size: 15px; }
.branch-card.accent-branchA { background: linear-gradient(135deg, #ffb057, var(--orange)); }
.branch-card.accent-branchB { background: linear-gradient(135deg, #6fb6ff, var(--blue-deep)); }
.branch-card.accent-branchC { background: linear-gradient(135deg, #b98bff, var(--purple)); }
.branch-card .metric-bar { background: rgba(255,255,255,.35); }
.branch-card .metric-fill { background: #fff; }
.branch-card .metric-top { color: #fff; }

/* 未来カード */
.future-card { border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; border-left: 6px solid; background: #fbfdff; }
.future-card.tone-regret { border-color: var(--orange); }
.future-card.tone-relief { border-color: var(--blue); }
.future-card.tone-joy { border-color: var(--green); }
.future-card h4 { margin: 0 0 4px; font-size: 15px; }
.future-card p { font-size: 13px; color: var(--ink-soft); }

/* 行動リスト */
.action-chip {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 8px 0;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--green);
  color: #1c8a5f; background: #eafaf3; cursor: pointer; font-size: 13px; transition: all .15s ease;
}
.action-chip:hover { background: var(--green); color: #fff; }

/* 後悔一覧 */
.regret-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: #fbfdff; }
.regret-item .rhead { display: flex; justify-content: space-between; align-items: center; }
.regret-item .rage { font-weight: 700; }
.regret-item .rcat { font-size: 11px; color: var(--orange); border: 1px solid var(--orange); border-radius: 6px; padding: 1px 6px; }
.regret-item .rbody { font-size: 13px; margin-top: 6px; line-height: 1.6; }
.regret-item .rdel { font-size: 11px; color: #c0392b; background: none; border: none; cursor: pointer; margin-top: 6px; }
.regret-item .rdel:hover { text-decoration: underline; }

/* ボタン */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; transition: all .15s ease;
}
.btn:hover { border-color: var(--blue); }
.btn-accent { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-accent:hover { background: #f5901f; }
.btn.full { width: 100%; }

/* ---- モーダル ---- */
.modal { position: fixed; inset: 0; background: rgba(33,50,63,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: var(--radius); width: min(480px, 92vw); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.icon-btn { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--ink-soft); }
.form { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-soft); }
.form input, .form select, .form textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-size: 14px; color: var(--ink);
  font-family: inherit;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.form-note { font-size: 11px; color: var(--ink-soft); line-height: 1.6; margin: 0; }
.privacy-card { border: 1px solid #ffd89a; background: #fff7e9; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.privacy-card h3 { margin: 0 0 6px; font-size: 13px; color: #8a5a12; }
.privacy-card p { margin: 0 0 4px; font-size: 12px; line-height: 1.7; color: #7a5a2a; }

/* ステージ右上の操作ボタン */
.stage-controls { position: absolute; right: 14px; top: 12px; display: flex; gap: 8px; z-index: 9; }
.stage-btn {
  border: 1px solid var(--line); background: rgba(255,255,255,.9); backdrop-filter: blur(4px);
  color: var(--ink); padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 13px;
  box-shadow: var(--shadow); transition: all .15s ease;
}
.stage-btn:hover { border-color: var(--blue); color: var(--blue-deep); }
.stage-btn.is-on { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ウォークモードのガイド */
.walk-hud {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
  background: rgba(33,50,63,.82); color: #fff; padding: 10px 16px; border-radius: 12px;
  display: flex; flex-direction: column; gap: 3px; align-items: center; font-size: 12px;
  box-shadow: 0 8px 20px rgba(0,0,0,.25); z-index: 9;
}
.walk-hud b { font-size: 13px; margin-bottom: 2px; }
.walk-hud[hidden] { display: none; }
.stage-btn[hidden] { display: none; }

/* AI仮想シナリオである旨の但し書き */
.disclaimer {
  display: flex; gap: 8px; align-items: flex-start;
  background: #fff7e9; border: 1px solid #ffd89a; color: #8a5a12;
  border-radius: 10px; padding: 9px 11px; font-size: 12px; line-height: 1.6; margin: 10px 0;
}
.disclaimer .ic { flex: 0 0 auto; }
.ai-badge { display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.ai-badge.ai { background: #e6f2ff; color: #155a9e; border: 1px solid #9cc9ff; }
.ai-badge.mock { background: #eef1f4; color: #6b7c8a; border: 1px solid #d5dee6; }

/* 6指標グリッド（別世界） */
.metrics6 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 6px; }

/* 未来の自分ボタン列 */
.self-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* タイムライン（別世界の未来の出来事） */
.tl { list-style: none; margin: 8px 0 0; padding: 0; }
.tl li { position: relative; padding: 4px 0 8px 18px; font-size: 13px; }
.tl li::before { content: ''; position: absolute; left: 4px; top: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.tl li::after { content: ''; position: absolute; left: 7px; top: 15px; bottom: -2px; width: 2px; background: var(--line); }
.tl li:last-child::after { display: none; }
.tl .tage { font-weight: 700; margin-right: 6px; }

/* ---- 未来の自分チャット ---- */
.chat-note {
  display: flex; gap: 8px; align-items: flex-start;
  background: #eef6ff; border: 1px solid #b9d9ff; color: #1d5aa0;
  border-radius: 10px; padding: 8px 11px; font-size: 12px; line-height: 1.6; margin: 8px 0 10px;
}
.chat-log {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 46vh; overflow-y: auto; padding: 4px 2px; margin-bottom: 10px;
}
.chat-msg { max-width: 90%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.6; white-space: normal; }
.chat-msg.user { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.assistant { align-self: flex-start; background: #eef7f1; border: 1px solid #cdeadb; color: var(--ink); border-bottom-left-radius: 4px; }
.chat-msg.assistant .chat-body { margin-top: 2px; }
.chat-msg.typing { color: var(--ink-soft); font-style: italic; background: #f2f6f9; border-color: var(--line); }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form textarea {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-family: inherit;
  font-size: 14px; resize: vertical; min-height: 40px;
}
.chat-form textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
.chat-actions { display: flex; gap: 8px; margin-top: 10px; }
.chat-actions .btn { flex: 1; }

/* ---- Phase4: 助言→行動 ---- */
.btn.tiny { font-size: 11px; padding: 5px 10px; border-radius: 8px; margin-top: 8px; }
.bring-btn { background: #f4fbe4; border-color: #a6c95a; color: #5c7a1e; }
.bring-btn:hover { background: #ecf6d4; }
#brought-list { display: flex; flex-direction: column; gap: 6px; }
.brought-item { display: flex; justify-content: space-between; align-items: center; text-align: left; font-size: 13px; }
.brought-item .bmeta { font-size: 11px; color: var(--ink-soft); margin-left: 8px; }

/* 軽いトースト（達成感を出しすぎない落ち着いたトーン） */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  background: rgba(33,50,63,.94); color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: 13px; box-shadow: 0 10px 26px rgba(0,0,0,.28); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .3s ease, transform .3s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- レスポンシブ（スマホでも最低限閲覧可能） ---- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; }
  .panel-left, .panel-right { border: none; border-top: 1px solid var(--line); }
  .stage { height: 60vh; min-height: 320px; }
  .panel-left { display: block; }
  .event-list { flex: none; max-height: 260px; }
  .panel-right { max-height: none; }
  .panel-scroll { overflow: visible; }
  .nav { display: none; }
  .flow-strip { font-size: 11px; padding: 6px 10px; }
}
