/*
  参考画像（中央の球体を8枚のカードが囲み、発光線で繋がり、両端に計器、
  上下にステップ列、床にグリッド）の構造をそのまま組む。

  基調は青。**気分の色は --accent として JS が差し込む**ので、
  CSS 側には固定のアクセント色を置かない。
*/

:root {
  --bg-0: #071026;
  --bg-1: #0a1730;
  --panel: rgba(13, 32, 62, 0.78);
  --panel-2: rgba(9, 24, 48, 0.9);
  --line: rgba(90, 165, 245, 0.26);
  --line-2: rgba(90, 165, 245, 0.5);
  --ink: #c3d8f5;
  --ink-dim: #7290bb;
  --ink-hi: #ffffff;
  --accent: #4db8ff;
  --accent-soft: rgba(77, 184, 255, 0.22);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --jp: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background:
    radial-gradient(140% 90% at 50% -10%, var(--bg-1) 0%, var(--bg-0) 62%),
    var(--bg-0);
  color: var(--ink);
  font-family: var(--jp);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 気分の色を画面全体にうっすら */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(46% 40% at 50% 42%, var(--accent-soft) 0%, transparent 72%);
  transition: background 1.4s ease;
}

/* 床。奥に向かって伸びるグリッド */
.grid-floor {
  position: fixed;
  left: -30%;
  right: -30%;
  bottom: 0;
  height: 46vh;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(90, 165, 245, 0.30) 0 1px, transparent 1px 74px),
    repeating-linear-gradient(0deg, rgba(90, 165, 245, 0.24) 0 1px, transparent 1px 52px);
  transform: perspective(400px) rotateX(74deg);
  transform-origin: bottom center;
  -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,.9) 0%, transparent 78%);
  mask-image: linear-gradient(to top, rgba(0,0,0,.9) 0%, transparent 78%);
}

.board {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 26px 20px calc(28px + env(safe-area-inset-bottom));
}

/* --- タイトル ------------------------------------------------------------- */

.title { text-align: center; margin-bottom: 16px; }

.title h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--ink-hi);
}

.title p {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: var(--accent);
  transition: color 1.4s ease;
}

/* --- 全体 ----------------------------------------------------------------- */

.frame {
  position: relative;
  display: grid;
  grid-template-columns: 116px 250px minmax(0, 1fr) 250px 116px;
  gap: 12px;
  align-items: start;
}

/* コネクタ。カードと球体の下に敷く */
.wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: visible;
}

.wire {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  opacity: 0.5;
  transition: stroke 1.2s ease;
}

.wire-node {
  fill: var(--accent);
  transition: fill 1.2s ease;
}

.rail, .cards, .center { position: relative; z-index: 1; }

/* --- 計器 ----------------------------------------------------------------- */

.rail { display: grid; gap: 11px; }

.gauge {
  position: relative;
  padding: 11px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel-2);
  text-align: center;
}

.gauge-k {
  margin: 0 0 5px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.18em;
  color: var(--accent);
  transition: color 1.4s ease;
}

.gauge-s {
  margin: 4px 0 0;
  font-size: 9px;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.gauge-big {
  margin: 3px 0 0;
  font-family: var(--mono);
  font-size: 19px;
  color: var(--ink-hi);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.gauge-hex { font-size: 14px; }

.bar {
  display: block;
  height: 3px;
  margin-top: 6px;
  background: rgba(90, 165, 245, 0.16);
  border-radius: 2px;
  overflow: hidden;
}

.bar b {
  display: block;
  height: 100%;
  width: 50%;
  background: var(--accent);
  transition: width 0.9s cubic-bezier(0.25, 0.8, 0.3, 1), background-color 1.2s ease;
}

.chip {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
  transition: background-color 1.2s ease;
}

/* ドーナツ */
.dial {
  --pct: 0;
  position: relative;
  width: 76px;
  height: 76px;
  margin: 2px auto 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), rgba(90, 165, 245, 0.16) 0);
  transition: background 0.9s ease;
}

.dial::before {
  content: "";
  position: absolute;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--panel-2);
}

.dial b {
  position: relative;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-hi);
  font-variant-numeric: tabular-nums;
}

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

.cards { display: grid; gap: 11px; }

.card {
  position: relative;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  box-shadow: inset 0 0 22px rgba(77, 184, 255, 0.05);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.ico {
  flex: none;
  width: 22px;
  height: 22px;
  color: var(--accent);
  transition: color 1.2s ease;
}

.card h2 {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--ink-hi);
}

.card ul { margin: 0; padding: 0; list-style: none; }

.card li {
  position: relative;
  padding-left: 13px;
  font-size: 10.5px;
  line-height: 1.8;
  color: var(--ink);
}

/* 画像のチェックマークに合わせる */
.card li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  font-size: 9px;
  color: var(--accent);
  transition: color 1.2s ease;
}

.fine { margin: 4px 0 0; font-size: 9px; color: var(--ink-dim); }

/* --- 中央 ----------------------------------------------------------------- */

.center { display: grid; gap: 11px; }

.engine {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
}

.engine h2 {
  margin: 0 0 9px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--ink-hi);
  text-align: center;
}

.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* ステップ間の矢印 */
.steps li:not(:last-child) { position: relative; padding-right: 40px; }

.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 17px;
  width: 24px;
  height: 1px;
  background: var(--accent);
  transition: background 1.2s ease;
}

.steps li:not(:last-child)::before {
  content: "";
  position: absolute;
  right: 8px;
  top: 14px;
  border: 3px solid transparent;
  border-left-color: var(--accent);
  transition: border-color 1.2s ease;
}

.step-ico {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: rgba(90, 165, 245, 0.08);
  color: var(--accent);
  transition: color 1.2s ease, border-color 1.2s ease;
}

.step-ico svg { width: 17px; height: 17px; }

.steps b {
  font-size: 10px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.04em;
}

/* 球体 */
.orb {
  position: relative;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: radial-gradient(60% 50% at 50% 45%, rgba(20, 50, 95, 0.5) 0%, #050d1e 70%);
  overflow: hidden;
}

#core { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

/* 球の下・台座の手前に置く。**球の中心を上げてこの位置を空けている**
   （下げすぎると台座のリングと文字が重なって読めなくなる） */
.orb-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 40px;
  text-align: center;
  pointer-events: none;
}

.orb-name {
  margin: 0;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink-hi);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.8);
}

.orb-sub {
  margin: 5px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--ink);
  opacity: 0.82;
}

.orb-badge {
  position: absolute;
  top: 11px;
  right: 11px;
  padding: 3px 9px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--accent);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: rgba(9, 24, 48, 0.7);
  transition: color 1.2s ease;
}

.orb-badge.is-local { color: #e8b062; }

.wave-wrap {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
}

#wave { display: block; width: 100%; height: 42px; }

/* --- ログ・根拠・帯 ------------------------------------------------------- */

.card--src .sources { max-height: 104px; overflow-y: auto; scrollbar-width: thin; }

.src {
  margin: 0 0 3px;
  padding-left: 11px;
  position: relative;
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.55;
  color: var(--ink);
  word-break: break-all;
}

.src::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--accent);
  transition: color 1.2s ease;
}

.card--log .log {
  height: 176px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 10px;
  scrollbar-width: thin;
}

.log-line {
  padding: 3px 0 3px 6px;
  border-left: 2px solid var(--edge, transparent);
  margin-bottom: 3px;
}

.log-t, .log-who { color: var(--ink-dim); margin-right: 4px; }

.log-body {
  margin: 2px 0 0;
  font-family: var(--jp);
  font-size: 11px;
  line-height: 1.65;
  color: var(--ink);
  word-break: break-word;
}

.log-line--ai .log-body { color: #a2bade; }

.log-tag {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  color: var(--accent);
  transition: color 1.2s ease;
}

.ribbon {
  display: flex;
  height: 34px;
  margin-top: 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  background: rgba(90, 165, 245, 0.06);
}

.ribbon-cell {
  flex: 1 1 0;
  min-width: 2px;
  animation: grow 0.7s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes grow { from { flex-grow: 0.02; } to { flex-grow: 1; } }

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

.status {
  min-height: 15px;
  margin: 18px 0 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-dim);
  text-align: center;
}

.composer {
  display: flex;
  gap: 8px;
  align-items: center;
  max-width: 820px;
  margin: 0 auto;
}

button, input { font-family: inherit; }

.mic {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--ink-hi);
  background: rgba(90, 165, 245, 0.12);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}

.mic:hover { background: rgba(90, 165, 245, 0.2); }

.mic-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  transition: background-color 1.2s ease;
}

.mic.is-recording { border-color: rgba(235, 95, 95, 0.65); }
.mic.is-recording .mic-dot { background: #eb5f5f; animation: blink 1.05s ease-in-out infinite; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

#text {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  font-size: 15px;
  color: var(--ink-hi);
  background: rgba(90, 165, 245, 0.08);
  border: 1px solid var(--line);
  border-radius: 3px;
}

#text::placeholder { color: var(--ink-dim); }
#text:focus { outline: none; border-color: var(--line-2); }

.send, .sound {
  padding: 11px 16px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--ink);
  background: rgba(90, 165, 245, 0.08);
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
}

.sound { font-family: var(--mono); font-size: 10.5px; color: var(--ink-dim); }
.sound[aria-pressed="false"] { opacity: 0.5; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  margin-top: 11px;
}

.chips button {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--ink-dim);
  background: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
}

.chips button:hover { color: var(--ink-hi); border-color: var(--line-2); }

.is-busy .mic, .is-busy .send { opacity: 0.4; pointer-events: none; }

/* --- 説明 ----------------------------------------------------------------- */

.note {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 26px auto 0;
  padding: 16px 20px 40px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.8;
  color: var(--ink-dim);
  text-align: center;
}

.note h2 {
  margin: 18px 0 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.08em;
}

.note h2:first-child { margin-top: 0; }
.note p { margin: 0 0 10px; max-width: 78ch; }
.note b { color: var(--ink-hi); font-weight: 600; }
.note .fine { font-size: 11.5px; }

/* --- 狭い画面 ------------------------------------------------------------- */

@media (max-width: 1240px) {
  .frame { grid-template-columns: 104px 1fr 104px; }
  .center { grid-column: 2; grid-row: 1; }
  .rail--l { grid-column: 1; grid-row: 1; }
  .rail--r { grid-column: 3; grid-row: 1; }
  .cards--l { grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(2, 1fr); }
  .cards--r { grid-column: 1 / -1; grid-row: 3; grid-template-columns: repeat(2, 1fr); }
  .wires { display: none; }
}

@media (max-width: 760px) {
  .board { padding: 16px 11px; }
  .title h1 { font-size: 27px; }
  .frame { grid-template-columns: 1fr; }
  .center, .rail--l, .rail--r, .cards--l, .cards--r { grid-column: 1; grid-row: auto; }
  .rail { grid-template-columns: repeat(2, 1fr); }
  .cards--l, .cards--r { grid-template-columns: 1fr; }
  .orb { min-height: 48vh; }
  .steps li:not(:last-child) { padding-right: 22px; }
  .steps li:not(:last-child)::after { width: 10px; }
  .step-ico { width: 30px; height: 30px; }
  .flow ol { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .flow li:not(:last-child)::after, .flow li:not(:last-child)::before { display: none; }
  .impact ul { grid-template-columns: repeat(2, 1fr); }
  .impact li { border-left: none; }
  .composer { flex-wrap: wrap; }
  .mic { flex: 1 1 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .ribbon-cell { animation: none; }
  .mic.is-recording .mic-dot { animation: none; }
  .grid-floor { display: none; }
}

/* --- 声で話しかける口（球体の直下・ファーストビュー内） ------------------- */
/*
  以前は画面の一番下に置いていたが、**スクロールしないと話しかけられなかった**。
  声で使う道具なので、球体の真下＝最初に見える位置に置く。
*/

.talk {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel-2);
  text-align: center;
}

.talk .mic {
  width: 100%;
  justify-content: center;
  padding: 13px 22px;
  font-size: 14px;
  letter-spacing: 0.16em;
  background: rgba(90, 165, 245, 0.16);
  border-color: var(--line-2);
}

.talk .mic:hover { background: rgba(90, 165, 245, 0.26); }

.talk-row {
  display: flex;
  gap: 7px;
  margin-top: 9px;
}

.talk .status {
  min-height: 14px;
  margin: 9px 0 0;
  text-align: center;
}

.talk .chips { margin-top: 9px; }
.talk .chips button { font-size: 10.5px; padding: 5px 10px; }

/* 下に残っていた composer は使わない */
.board > .composer, .board > .chips, .board > .status { display: none; }

@media (max-width: 760px) {
  .talk-row { flex-wrap: wrap; }
  .talk-row #text { flex: 1 1 100%; }
}

/* --- 処理のログ ----------------------------------------------------------- */
/*
  答えの文だけを並べても「何を見て答えたのか」が分からない。
  検索した語・読んだファイル・カレンダーを見た事実を、処理の順に出す。
*/

.log-step {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 2px 0 2px 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--ink-dim);
  word-break: break-all;
}

.log-kind {
  flex: none;
  min-width: 58px;
  padding: 1px 5px;
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-align: center;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: color 1.2s ease;
}

.log-who {
  display: inline-block;
  min-width: 48px;
  font-size: 8.5px;
  letter-spacing: 0.1em;
}

.log-line--you .log-who { color: var(--ink-hi); }

/* 読んだファイルは目立たせる（「何を見ているか」がこの画面の要） */
.log-step[data-kind="BASE"] .log-kind,
.log-step[data-kind="READ"] .log-kind {
  color: var(--ink-hi);
  border-color: var(--line-2);
  background: rgba(90, 165, 245, 0.14);
}
.log-step[data-kind="BASE"] span,
.log-step[data-kind="READ"] span { color: var(--ink); }
.log-kind { min-width: 66px; }

/* --- 実データの一覧（予定・未決・直近） ----------------------------------- */
/*
  ここには以前「読んでいる記録の一覧」「検索のやり方」という仕様説明を並べていたが、
  毎回同じ文字が出るだけで見る意味がなかった。**その時どきで変わる中身**に置き換えた。
*/

.feed { max-height: 132px; overflow-y: auto; scrollbar-width: thin; }

.feed-row {
  position: relative;
  padding: 3px 0 3px 12px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--ink);
  word-break: break-word;
}

.feed-row::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 9px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  transition: background-color 1.2s ease;
}

.feed-time {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-hi);
  margin-right: 6px;
}

.feed-empty { color: var(--ink-dim); font-size: 10px; padding-left: 2px; }

#loop-count {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--accent);
  transition: color 1.2s ease;
}

/* --- 全画面レイアウト ----------------------------------------------------- */
/*
  横に余白が空き、下にも空きが出ていたので、**画面いっぱいに敷き詰める**。
  中身（予定・未決・ログ）は伸びた分だけ多く見えるようにし、
  はみ出す分はカードの中だけでスクロールさせる（ページ自体は動かさない）。
  狭い画面では従来どおり縦に積むので、この指定は広い画面だけに効かせる。
*/

@media (min-width: 1180px) and (min-height: 660px) {
  html, body { height: 100%; overflow: hidden; }

  .board {
    max-width: none;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 14px 18px 10px;
    gap: 10px;
  }

  .title { flex: none; margin-bottom: 0; }
  .title h1 { font-size: 32px; }
  .title p { margin-top: 4px; }

  .frame {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-columns: 132px 268px minmax(0, 1fr) 300px 132px;
    align-items: stretch;
  }

  /* 縦を等分して、カードを画面いっぱいに伸ばす */
  .rail, .cards { grid-template-rows: repeat(4, minmax(0, 1fr)); height: 100%; }
  .cards--r { grid-template-rows: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1.1fr); }

  .card, .gauge {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .card ul, .feed, .sources, .log { min-height: 0; flex: 1 1 auto; max-height: none; }
  .feed, .sources, .log { overflow-y: auto; }

  /* 中央は球体を主役に、下に波形と入力 */
  .center {
    height: 100%;
    grid-template-rows: minmax(0, 1fr) auto auto;
  }

  .orb { min-height: 0; height: 100%; }
  .orb-label { bottom: 30px; }
  .orb-name { font-size: 30px; }

  .talk { flex: none; }
  .talk .chips { display: none; }   /* 全画面では例文チップを畳んで高さを稼ぐ */

  /* 説明は最下部に1行だけ残す */
  .note {
    flex: none;
    margin: 0;
    padding: 6px 0 0;
    max-width: none;
    font-size: 9.5px;
    line-height: 1.5;
    border-top: 1px solid var(--line);
  }
  .note p { margin: 0; max-width: none; }

  .grid-floor { height: 34vh; opacity: 0.6; }
}

/* 全画面のとき、中身が縮まずに画面からはみ出していたので、
   grid/flex の子に min-height: 0 を効かせて確実に収める */
@media (min-width: 1180px) and (min-height: 660px) {
  .frame > * { min-height: 0; }
  .center > * { min-height: 0; }
  .cards > .card, .rail > .gauge { overflow: hidden; }
  .board { overflow: hidden; }
  .note { padding-bottom: 2px; }
}

/* 公開版では左のカードが1枚だけになるので、縦に伸びすぎないようにする */
.cards--l .card[hidden] { display: none; }
@media (min-width: 1180px) and (min-height: 660px) {
  .cards--l:has(.card[hidden]) { grid-template-rows: auto; align-content: start; }
}
