/* =====================================================================
   共通スタイル — 資産家感覚ビジネスビルダー

   Bootstrap 5（data-bs-theme="dark"）の上に、このアプリの言葉づかいを重ねる。
   色の意味は1つだけ決めてある: 資源の3色は教材のROI順（ヒト→モノ→カネ）で
   暖色→寒色に並ぶ。画面のどこで見ても同じ色が同じ資源を指す。
   ===================================================================== */

:root {
  --bg:        #0f1115;
  --bg-soft:   #171a21;
  --bg-card:   #1b1f28;
  --line:      #2a3040;
  --line-soft: #222836;
  --text:      #e6e9ef;
  --muted:     #8b93a7;

  --hito: #f0b429;   /* ヒト資源 — 最もROIが高い */
  --mono: #2dd4bf;   /* モノ資源 */
  --kane: #a78bfa;   /* カネ資源 — 最もROIが低い */

  --ok:   #34d399;
  --warn: #fbbf24;
  --ng:   #f87171;

  --radius: 14px;
}

/* ------------------------------------------------------------------ 土台 */

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
               "Noto Sans JP", "Segoe UI", sans-serif;
  font-feature-settings: "palt";
  letter-spacing: .01em;
  padding-bottom: 4rem;
}

a { color: #7dd3fc; text-decoration: none; }
a:hover { color: #bae6fd; text-decoration: underline; }

.muted { color: var(--muted); }
.tiny  { font-size: .78rem; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- ヘッダ */

.app-header {
  background: linear-gradient(180deg, #141821 0%, #0f1115 100%);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
}
.app-header .brand {
  font-weight: 700; font-size: 1.02rem; color: var(--text);
  display: flex; align-items: center; gap: .5rem;
}
.app-header .brand:hover { text-decoration: none; color: #fff; }
.app-header .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--hito), var(--mono) 55%, var(--kane));
}
.app-nav { display: flex; gap: .15rem; flex-wrap: wrap; }
.app-nav a {
  color: var(--muted); padding: .35rem .7rem; border-radius: 999px;
  font-size: .89rem; white-space: nowrap;
}
.app-nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.app-nav a.active { background: var(--bg-card); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------------------------------------------------------------- カード */

.card-x {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.card-x + .card-x { margin-top: .8rem; }
.card-x h2, .card-x h3 { font-size: 1rem; font-weight: 700; margin: 0 0 .6rem; }

.section-title {
  font-size: .8rem; font-weight: 700; letter-spacing: .12em;
  color: var(--muted); text-transform: uppercase;
  margin: 1.6rem 0 .6rem;
}

/* -------------------------------------------------------------- 資源の色 */

.kind-hito { --kind: var(--hito); }
.kind-mono { --kind: var(--mono); }
.kind-kane { --kind: var(--kane); }
.kind-note { --kind: #94a3b8; }

.kind-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 700; padding: .12rem .5rem;
  border-radius: 999px; color: var(--kind);
  background: color-mix(in srgb, var(--kind) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--kind) 38%, transparent);
}

.pill {
  display: inline-block; font-size: .72rem; padding: .1rem .5rem;
  border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: var(--bg-soft);
}
.pill.tag { cursor: pointer; }
.pill.tag:hover { border-color: #4b5563; color: var(--text); }

/* 資源カード */
.res-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--kind, var(--line));
  border-radius: 12px;
  padding: .8rem .9rem;
  height: 100%;
  transition: border-color .15s, transform .1s;
}
.res-card:hover { border-color: color-mix(in srgb, var(--kind) 55%, var(--line)); }
.res-card .name { font-weight: 700; font-size: .97rem; }
.res-card .summary {
  color: var(--muted); font-size: .84rem; margin-top: .25rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.res-card .foot { margin-top: .55rem; display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }

/* 5段階メーター */
.rate { display: inline-flex; gap: 2px; vertical-align: middle; }
.rate i {
  width: 7px; height: 7px; border-radius: 2px; background: var(--line);
  display: inline-block;
}
.rate i.on { background: var(--kind, var(--ok)); }

/* ------------------------------------------------------------ 進捗の帯 */

.bar { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--ok); }

/* 10ステップの旅 */
.journey { display: flex; gap: 4px; }
.journey .leg {
  flex: 1 1 0; min-width: 0; border-radius: 8px; padding: .5rem .5rem .55rem;
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  position: relative; overflow: hidden; text-align: left;
  color: inherit;
}
.journey .leg:hover { text-decoration: none; border-color: var(--line); }
.journey .leg .fill {
  position: absolute; left: 0; bottom: 0; height: 3px; background: var(--legcolor, var(--ok));
}
.journey .leg .n { font-size: .68rem; color: var(--muted); }
.journey .leg .nm {
  font-size: .78rem; font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.journey .leg .pc { font-size: .68rem; color: var(--muted); }
.journey .leg.here { border-color: var(--legcolor); box-shadow: 0 0 0 1px var(--legcolor) inset; }

@media (max-width: 780px) {
  .journey { flex-wrap: wrap; }
  .journey .leg { flex: 1 1 30%; }
}

/* ------------------------------------------------------------ 講義の本文 */

.seg {
  display: flex; gap: .8rem; padding: .7rem .8rem;
  border-radius: 10px; border: 1px solid transparent;
}
.seg:hover { background: var(--bg-soft); border-color: var(--line-soft); }
.seg.target { background: #1e2637; border-color: #38507a; }
.seg .t {
  flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: .78rem;
  color: #7dd3fc; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: .1rem .5rem; height: fit-content; cursor: pointer;
}
.seg .t:hover { border-color: #38bdf8; color: #bae6fd; }
.seg .body { font-size: .93rem; line-height: 1.95; }
.seg .body mark { background: #4d3f14; color: #fde68a; padding: 0 .1em; border-radius: 3px; }

.player-bar {
  position: sticky; top: 56px; z-index: 50;
  background: rgba(15,17,21,.94); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 12px; padding: .5rem .7rem;
}
.player-bar audio { width: 100%; height: 34px; }

/* ------------------------------------------------------------ キャンバス */

.builder-wrap { display: flex; gap: .8rem; align-items: flex-start; }
.palette {
  flex: 0 0 270px; max-height: calc(100vh - 130px); overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .7rem;
}
.palette .p-item {
  border: 1px solid var(--line); border-left: 3px solid var(--kind, var(--line));
  border-radius: 9px; padding: .4rem .55rem; margin-bottom: .35rem;
  cursor: grab; background: var(--bg-soft); font-size: .84rem;
}
.palette .p-item:active { cursor: grabbing; }
.palette .p-item .nm { font-weight: 600; }
.palette .p-item .sm { color: var(--muted); font-size: .74rem; }

.canvas {
  position: relative; flex: 1 1 auto; min-height: 620px;
  background:
    linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px) 0 0 / 28px 100%,
    var(--bg-soft);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; touch-action: none;
}
.canvas.drop-on { border-color: var(--ok); }

/* 作る・売る・守るの3レーン（薄く敷いて、どこが手薄か目で分かるように） */
.lanes { position: absolute; inset: 0; display: flex; pointer-events: none; }
.lane { flex: 1 1 0; border-right: 1px dashed rgba(255,255,255,.07); position: relative; }
.lane:last-child { border-right: none; }
.lane .lane-label {
  position: absolute; top: 8px; left: 10px; font-size: .72rem;
  letter-spacing: .18em; color: rgba(255,255,255,.22); font-weight: 700;
}

.node {
  position: absolute; width: 168px; user-select: none; cursor: grab;
  background: var(--bg-card); border: 1px solid var(--line);
  border-top: 3px solid var(--kind, var(--line));
  border-radius: 10px; padding: .45rem .55rem .5rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.35); z-index: 2;
}
.node:active { cursor: grabbing; }
.node.sel { border-color: #7dd3fc; box-shadow: 0 0 0 2px rgba(125,211,252,.4), 0 6px 18px rgba(0,0,0,.35); }
.node .nm { font-size: .82rem; font-weight: 700; line-height: 1.35; }
.node .sm { font-size: .7rem; color: var(--muted); margin-top: .15rem; }
.node .x {
  position: absolute; top: -8px; right: -8px; width: 20px; height: 20px;
  border-radius: 50%; background: #2a3040; color: var(--muted);
  font-size: .7rem; line-height: 20px; text-align: center; cursor: pointer;
  border: 1px solid var(--line); opacity: 0;
}
.node:hover .x { opacity: 1; }
.node .x:hover { background: var(--ng); color: #fff; }

.edges { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.edges line { stroke: #4b5563; }

/* ---------------------------------------------------------------- 入力欄 */

.form-control, .form-select {
  background: var(--bg-soft); border-color: var(--line); color: var(--text);
}
.form-control:focus, .form-select:focus {
  background: var(--bg-soft); color: var(--text);
  border-color: #38bdf8; box-shadow: 0 0 0 .2rem rgba(56,189,248,.15);
}
.form-control::placeholder { color: #5c6478; }
.form-label { font-size: .84rem; font-weight: 600; margin-bottom: .2rem; }
.form-text { color: var(--muted); font-size: .76rem; }

.rate-input { display: flex; gap: .2rem; }
.rate-input button {
  flex: 1; border: 1px solid var(--line); background: var(--bg-soft);
  color: var(--muted); border-radius: 7px; padding: .25rem 0; font-size: .78rem;
}
.rate-input button.on { background: #26405a; border-color: #38bdf8; color: #bae6fd; }

/* --------------------------------------------------------------- ログイン */

.login-wrap {
  max-width: 340px; margin: 16vh auto 0; text-align: center; padding: 0 1rem;
}
.login-wrap h1 { font-size: 1.2rem; font-weight: 700; }
.login-wrap p { color: var(--muted); font-size: .85rem; margin-bottom: 1.4rem; }
.login-wrap .error { color: var(--ng); font-size: .84rem; min-height: 1.4em; margin: .4rem 0; }

/* ---------------------------------------------------------------- その他 */

.empty {
  text-align: center; color: var(--muted); padding: 2.4rem 1rem;
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.stat { text-align: center; }
.stat .n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: var(--kind, var(--text)); }
.stat .l { font-size: .74rem; color: var(--muted); }

.toast-x {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #232a38; border: 1px solid var(--line); color: var(--text);
  padding: .55rem 1rem; border-radius: 999px; font-size: .86rem;
  z-index: 2000; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}

.modal-content { background: var(--bg-card); border: 1px solid var(--line); }
.modal-header, .modal-footer { border-color: var(--line); }

.next-move {
  border: 1px solid var(--line); border-radius: 12px; padding: .7rem .85rem;
  background: var(--bg-soft); display: flex; gap: .7rem; align-items: flex-start;
}
.next-move .ico { font-size: 1.1rem; line-height: 1.4; }
.next-move .ttl { font-size: .86rem; font-weight: 700; }
.next-move .sub { font-size: .78rem; color: var(--muted); }
