/*
 * Capture — レトロ・ロービット / 16-bit フィールド端末
 * （docs/CAPTURE_V1_SPEC.md §3）
 *
 * Index のレトロフィッシング（紙・暖色）、Trip Detail のブルーノート（ネイビー・
 * 整理）とは意図的に別の世界観にする。ここは暗いフィールドで使う記録装置。
 *
 * 装飾より「暗所での視認性 / 操作速度 / 状態の分かりやすさ」を優先する:
 * - 角丸を使わない、境界は太い実線、影はぼかさない（ドット絵の平面感）
 * - 見出し・ラベル・数値は等幅＋大文字＋レタースペースでピクセル寄りに
 * - 本文と入力欄だけは日本語の可読性を優先してサンセリフ
 */
:root {
  color-scheme: dark;

  --bg: #0d120e;
  --bg-deep: #080b09;
  --panel: #e9e3cd;
  --panel-alt: #ddd6bd;
  --ink: #1a2016;
  --muted: #5f6551;

  --olive: #3f5027;
  --olive-bright: #55692f;
  --olive-dim: #2a3620;
  --cream: #f2ecd8;

  /* Capture Item の識別色（§10） */
  --observation: #4a7c3f;
  --decision: #a5382c;
  --event: #2f5f8a;
  --catch: #c2611e;
  --note: #6b6a53;

  --alert: #c9482f;

  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;

  --edge: 3px solid var(--ink);
  --drop: 4px 4px 0 rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

/*
 * hidden 属性を常に効かせる。この画面はモーダル・ドロップダウン・状態表示の
 * 出し分けを hidden で行っており、display を持つクラス（.overlay の grid 等）が
 * 当たると UA 標準の display:none が負けてしまうため。
 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background-color: var(--bg);
  /* うっすらした走査線。CRT の質感を出すが、本文の可読性は落とさない量に留める */
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.022) 0 1px,
    transparent 1px 3px
  );
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}

button,
input,
textarea,
a {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.cap-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ── Header ─────────────────────────────────────────────── */

.cap-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  margin: 0 -16px;
  padding: 0 16px;
  background: var(--bg-deep);
  border-bottom: 3px solid var(--olive);
}

.home-link {
  justify-self: start;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.home-link:hover {
  color: #fff;
}

.mode-switch {
  position: relative;
  justify-self: center;
}

.mode-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 2px solid var(--cream);
  background: var(--olive);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  white-space: nowrap;
}

/* Guide は「AIが意見を出す」状態なので、モード表示自体の色を変えて
   いまどちらで記録しているかを一目で分かるようにする */
.mode-button[data-mode="guide"] {
  background: var(--event);
}

.caret {
  font-size: 0.6rem;
}

.mode-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 40;
  min-width: 190px;
  padding: 10px 0 6px;
  border: var(--edge);
  background: var(--panel);
  box-shadow: var(--drop);
  transform: translateX(-50%);
}

.mode-menu-title {
  margin: 0 0 6px;
  padding: 0 14px 8px;
  border-bottom: 2px solid rgba(26, 32, 22, 0.25);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: left;
}

.mode-option:hover {
  background: rgba(63, 80, 39, 0.14);
}

.mode-option .check {
  width: 1em;
  color: var(--olive);
  visibility: hidden;
}

.mode-option[aria-checked="true"] .check {
  visibility: visible;
}

.info-button {
  justify-self: end;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid var(--cream);
  background: transparent;
  color: var(--cream);
  font-size: 1rem;
  line-height: 1;
}

.info-button:hover {
  background: var(--olive);
}

/* ── モック帯 ───────────────────────────────────────────── */

.mock-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 14px 0;
  padding: 10px 14px;
  border: 2px dashed var(--catch);
  color: #f4d9bf;
  background: rgba(194, 97, 30, 0.12);
  font-size: 0.8rem;
  line-height: 1.5;
}

.mock-banner strong {
  font-family: var(--mono);
  letter-spacing: 0.08em;
  color: #f0b483;
}

.mock-tag {
  padding: 3px 7px;
  border: 2px solid var(--catch);
  color: var(--catch);
  background: rgba(194, 97, 30, 0.1);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

/* ── レイアウト ─────────────────────────────────────────── */

.cap-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.cap-column {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.panel {
  padding: 14px;
  border: var(--edge);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--drop);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(26, 32, 22, 0.22);
}

.panel-head h2 {
  flex: 1;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

/* ── 現在の Trip ────────────────────────────────────────── */

.trip-panel {
  background: var(--olive-dim);
  color: var(--cream);
  border-color: var(--olive);
}

.trip-panel .panel-head {
  border-bottom-color: rgba(242, 236, 216, 0.24);
}

.trip-title {
  margin: 0 0 8px;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
}

.trip-state {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

.rec-dot {
  width: 10px;
  height: 10px;
  background: var(--alert);
}

.trip-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  margin: 0;
}

.trip-facts div {
  display: grid;
  gap: 2px;
}

.trip-facts dt {
  color: rgba(242, 236, 216, 0.6);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.trip-facts dd {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}

/* 実データで表示していることを示す。モックの MOCK バッジと対になる。 */
.live-tag {
  padding: 3px 7px;
  border: 2px solid var(--observation);
  color: #cfe6c6;
  background: rgba(74, 124, 63, 0.2);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.trip-loading,
.trip-error {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
}

.trip-error {
  padding: 10px 12px;
  border-left: 5px solid var(--alert);
  background: rgba(201, 72, 47, 0.18);
  line-height: 1.6;
}

/* ── 釣行の開始 ─────────────────────────────────────────── */

.start-lead {
  margin: 0 0 14px;
  color: rgba(242, 236, 216, 0.78);
  font-size: 0.9rem;
}

.start-label {
  display: block;
  margin-bottom: 6px;
  color: rgba(242, 236, 216, 0.6);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.start-input {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 2px solid rgba(242, 236, 216, 0.4);
  background: rgba(8, 11, 9, 0.4);
  color: var(--cream);
  font-size: 1rem;
}

.start-input:focus-visible {
  outline: 3px solid var(--olive-bright);
  outline-offset: 1px;
}

.start-input::placeholder {
  color: rgba(242, 236, 216, 0.35);
}

.start-input:disabled {
  opacity: 0.6;
}

.start-button {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 13px;
  border: 3px solid var(--cream);
  background: var(--olive-bright);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.start-button:hover:not(:disabled) {
  background: #66802f;
}

.start-button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.start-feedback {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-left: 5px solid rgba(242, 236, 216, 0.5);
  background: rgba(8, 11, 9, 0.3);
  font-size: 0.82rem;
  line-height: 1.6;
}

.start-feedback[data-status="ok"] {
  border-left-color: var(--observation);
  background: rgba(74, 124, 63, 0.22);
}

.start-feedback[data-status="error"] {
  border-left-color: var(--alert);
  background: rgba(201, 72, 47, 0.2);
}

/* ── Guide AI Opinion ───────────────────────────────────── */

/* ユーザー記録（クリーム面）と明確に分けるため、左に太い識別線を入れ、
   面の色も変える（§6.2「必ず視覚的にユーザー記録とAIの意見を分離する」） */
.opinion-panel {
  border-left: 10px solid var(--event);
  background: var(--panel-alt);
}

.opinion-panel .panel-head h2 {
  color: var(--event);
}

.opinion-body {
  display: grid;
  gap: 10px;
}

.opinion-text {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.7;
}

.opinion-reason {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 10px 12px;
  border: 2px solid rgba(47, 95, 138, 0.35);
  background: rgba(47, 95, 138, 0.08);
  font-size: 0.9rem;
  line-height: 1.65;
}

.opinion-reason-label {
  color: var(--event);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.opinion-note {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 2px dotted rgba(26, 32, 22, 0.3);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

/* ── AI からの応答（conversation_response / Phase 5） ────── */

/*
 * Opinion パネルとは別の見た目にする。片方は「AI の攻略意見（Guide のみ）」、
 * もう片方は「モードに関係なく返る会話文」で、性質が違う。
 */
.conversation-panel {
  border-left: 10px solid var(--observation);
  background: var(--panel-alt);
}

.conversation-panel .panel-head h2 {
  color: var(--observation);
}

.conversation-status {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.6;
}

.conversation-text {
  margin: 10px 0 0;
  font-size: 0.98rem;
  line-height: 1.7;
}

/* 解析待ち。Capture の保存は既に完了しているので、警告色にはしない。 */
.conversation-panel[data-state="pending"] {
  border-left-color: var(--muted);
}

.conversation-panel[data-state="pending"] .conversation-status,
.conversation-panel[data-state="note"] .conversation-status {
  color: var(--muted);
}

/*
 * AI 側だけが失敗した状態。記録は保存済みなので alert 一色にはせず、
 * 保存の失敗（record-feedback[data-status="error"]）と見分けられるようにする。
 */
.conversation-panel[data-state="ai_failed"],
.conversation-panel[data-state="unknown"] {
  border-left-color: var(--catch);
}

.conversation-panel[data-state="ai_failed"] .conversation-status,
.conversation-panel[data-state="unknown"] .conversation-status {
  color: var(--catch);
}

/* 失敗時の本文は AI の会話ではなく理由の説明なので、控えめに出す。 */
.conversation-panel[data-state="ai_failed"] .conversation-text {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ── Capture Input ──────────────────────────────────────── */

.capture-text {
  display: block;
  width: 100%;
  padding: 12px;
  border: 2px solid rgba(26, 32, 22, 0.45);
  background: #f6f2e2;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.65;
  resize: vertical;
}

.capture-text:focus-visible {
  outline: 3px solid var(--olive-bright);
  outline-offset: 1px;
}

.capture-text::placeholder {
  color: #9a9682;
}

.input-tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.tool {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 10px 4px;
  border: 2px solid rgba(26, 32, 22, 0.45);
  background: #f6f2e2;
  color: var(--ink);
}

.tool:hover {
  background: #fffbee;
}

.tool[data-active="true"] {
  border-color: var(--olive);
  background: rgba(63, 80, 39, 0.16);
}

.tool-icon {
  font-family: var(--mono);
  font-size: 1.15rem;
  line-height: 1;
}

.tool-name {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.tool-states {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.tool-state {
  margin: 0;
  padding: 8px 10px;
  border-left: 5px solid var(--muted);
  background: rgba(26, 32, 22, 0.05);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
}

.tool-state[data-status="pending"] {
  border-left-color: var(--catch);
}

.tool-state[data-status="ready"] {
  border-left-color: var(--observation);
}

.tool-state[data-status="failed"] {
  border-left-color: var(--alert);
}

.photo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.photo-list li {
  position: relative;
}

.photo-list img {
  display: block;
  width: 62px;
  height: 62px;
  border: 2px solid rgba(26, 32, 22, 0.45);
  object-fit: cover;
}

.photo-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 2px solid var(--ink);
  background: var(--alert);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.62rem;
  line-height: 1;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-left: 5px solid var(--olive);
  background: rgba(26, 32, 22, 0.05);
}

.time-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.time-value {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 700;
}

.time-edit,
.time-apply,
.time-reset {
  padding: 5px 9px;
  border: 2px solid rgba(26, 32, 22, 0.45);
  background: #f6f2e2;
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.time-manual {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.time-manual input {
  flex: 1 1 190px;
  min-width: 0;
  padding: 7px 9px;
  border: 2px solid rgba(26, 32, 22, 0.45);
  background: #f6f2e2;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.84rem;
}

.record-button {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 15px;
  border: var(--edge);
  background: var(--olive);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  box-shadow: 4px 4px 0 rgba(26, 32, 22, 0.45);
}

.record-button:hover {
  background: var(--olive-bright);
}

.record-button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 rgba(26, 32, 22, 0.45);
}

.record-feedback {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-left: 5px solid var(--observation);
  background: rgba(74, 124, 63, 0.12);
  font-size: 0.82rem;
  font-weight: 700;
}

.record-feedback[data-status="error"] {
  border-left-color: var(--alert);
  background: rgba(201, 72, 47, 0.12);
}

/* ── Timeline ───────────────────────────────────────────── */

.timeline-count {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-entry {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 2px solid rgba(26, 32, 22, 0.12);
}

.timeline-entry:last-child {
  border-bottom: 0;
}

.entry-time {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.entry-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border: 2px solid var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.badge.observation { background: var(--observation); }
.badge.decision    { background: var(--decision); }
.badge.event       { background: var(--event); }
.badge.catch       { background: var(--catch); }
.badge.note        { background: var(--note); }

.entry-source {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.entry-body {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/*
 * AI の行。本文（＝保存された事実）とは見た目を変え、ラベルを必ず添える。
 * 同じ見た目にすると「記録したこと」と「AI が解釈したこと」が混ざる
 * （CLAUDE.md / docs/AI_RULES.md）。
 */
.entry-ai {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin: 0;
  padding: 5px 0 5px 9px;
  border-left: 3px solid var(--muted);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.entry-ai-label {
  flex: none;
  padding: 2px 6px;
  background: var(--muted);
  color: var(--panel);
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.entry-ai-text {
  min-width: 0;
}

/* 保存済みの AI 要約。状態表示ではなく中身なので、本文に次ぐ強さで出す。 */
.entry-ai[data-status="summary"] {
  border-left-color: var(--event);
  color: var(--ink);
}

.entry-ai[data-status="summary"] .entry-ai-label {
  background: var(--event);
  color: #fff;
}

/*
 * AI 側だけが失敗した状態。記録は保存済みなので alert 一色にはしない
 * （.conversation-panel[data-state="ai_failed"] と同じ扱い）。
 */
.entry-ai[data-status="failed"],
.entry-ai[data-status="unknown"] {
  border-left-color: var(--catch);
  color: var(--catch);
}

.entry-ai[data-status="failed"] .entry-ai-label,
.entry-ai[data-status="unknown"] .entry-ai-label {
  background: var(--catch);
  color: #fff;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.timeline-empty {
  margin: 0;
  padding: 18px 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

/* ── Trip End ───────────────────────────────────────────── */

.end-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.end-button {
  display: block;
  width: 100%;
  padding: 13px;
  border: 3px solid var(--alert);
  background: transparent;
  color: var(--decision);
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.end-button:hover {
  background: var(--alert);
  color: #fff;
}

/* ── モーダル ───────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 11, 9, 0.82);
  overflow-y: auto;
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border: var(--edge);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--drop);
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 3px solid var(--ink);
  background: var(--olive);
  color: var(--cream);
}

.modal-head h2 {
  flex: 1;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.modal-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid var(--cream);
  background: transparent;
  color: var(--cream);
  font-size: 0.8rem;
  line-height: 1;
}

.modal-close:hover {
  background: var(--alert);
}

.modal-body {
  padding: 14px;
}

.modal-body h3 {
  margin: 16px 0 6px;
  color: var(--olive);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body p {
  margin: 0 0 8px;
  font-size: 0.9rem;
  line-height: 1.7;
}

.info-list {
  margin: 0;
  padding-left: 1.2em;
  font-size: 0.88rem;
  line-height: 1.8;
}

.info-list.legend {
  padding-left: 0;
  list-style: none;
}

/* バッジ幅が種別ごとに違うと説明文の折返し位置が揃わないので、
   バッジ列の幅を固定して2列で読ませる */
.info-list.legend li {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.info-list.legend .badge {
  justify-self: start;
}

.info-foot {
  margin: 18px 0 0;
  padding-top: 10px;
  border-top: 2px solid rgba(26, 32, 22, 0.22);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-align: center;
}

.end-phase-note {
  padding: 8px 10px;
  border-left: 5px solid var(--catch);
  background: rgba(194, 97, 30, 0.1);
  font-size: 0.82rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  padding: 14px;
  border-top: 2px solid rgba(26, 32, 22, 0.22);
}

/* ── 書き込みトークン ───────────────────────────────────── */

.token-input {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 11px 12px;
  border: 2px solid rgba(26, 32, 22, 0.45);
  background: #f6f2e2;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.9rem;
}

.token-input:focus-visible {
  outline: 3px solid var(--olive-bright);
  outline-offset: 1px;
}

.token-note {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.65;
}

.token-note code {
  padding: 1px 5px;
  border: 1px solid rgba(26, 32, 22, 0.3);
  background: rgba(26, 32, 22, 0.06);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.token-status {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-left: 5px solid var(--muted);
  background: rgba(26, 32, 22, 0.05);
  font-size: 0.82rem;
  font-weight: 700;
}

.token-status[data-status="error"] {
  border-left-color: var(--alert);
  background: rgba(201, 72, 47, 0.12);
}

.info-token-state {
  padding: 8px 10px;
  border-left: 5px solid var(--olive);
  background: rgba(26, 32, 22, 0.05);
  font-family: var(--mono);
  font-size: 0.82rem;
}

.info-token-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.info-btn {
  padding: 8px 12px;
  border: 2px solid var(--ink);
  background: var(--panel-alt);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.info-btn:hover {
  background: #cfc7ab;
}

.info-btn.danger {
  border-color: var(--alert);
  color: var(--decision);
}

.info-btn.danger:hover {
  background: var(--alert);
  color: #fff;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  flex: 1;
  padding: 12px;
  border: 3px solid var(--ink);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.btn-primary {
  border-color: var(--olive);
  background: var(--olive);
  color: var(--cream);
}

.btn-primary:hover {
  background: var(--olive-bright);
}

.btn-secondary {
  background: var(--panel-alt);
  color: var(--ink);
}

.btn-secondary:hover {
  background: #cfc7ab;
}

.btn-danger {
  border-color: var(--alert);
  background: var(--alert);
  color: #fff;
}

.btn-danger:hover {
  background: #a63a24;
}

/* ── スマートフォン ─────────────────────────────────────── */

@media (max-width: 860px) {
  body {
    font-size: 15px;
  }

  .cap-shell {
    padding: 0 10px 32px;
  }

  .cap-header {
    margin: 0 -10px;
    padding: 0 10px;
    gap: 8px;
  }

  .home-link {
    font-size: 0.74rem;
    letter-spacing: 0.06em;
  }

  .mode-button {
    padding: 6px 9px;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
  }

  /* 画面端でメニューが切れないよう、中央寄せをやめて右端に合わせる */
  .mode-menu {
    left: auto;
    right: 0;
    transform: none;
  }

  .cap-layout {
    grid-template-columns: 1fr;
  }

  .trip-title {
    font-size: 1.15rem;
  }

  .input-tools {
    gap: 6px;
  }

  .tool {
    padding: 9px 2px;
  }

  .tool-name {
    font-size: 0.62rem;
  }

  .timeline-entry {
    grid-template-columns: 46px 1fr;
    gap: 9px;
  }

  .modal-actions {
    flex-direction: column;
  }
}
