/* KabuAI - 共通スタイル & 詳細画面 */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

.container { max-width: 720px; margin: 0 auto; padding: 24px 16px calc(104px + env(safe-area-inset-bottom)); width: 100%; overflow-x: clip; }

/* Back link */
.back-link {
  display: inline-block;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 12px;
  text-decoration: none;
}
.back-link:hover { color: var(--accent-hover); }

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 10px;
}

.app-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(15,17,23,0.92);
  backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.app-tabs-inner {
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.app-tab {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.73rem;
  font-weight: 700;
  line-height: 1.2;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  -webkit-tap-highlight-color: transparent;
}

.app-tab.active {
  color: #e0e7ff;
  background: rgba(99,102,241,0.18);
  border-color: rgba(99,102,241,0.45);
}

.app-tab:active { background: rgba(255,255,255,0.06); }

.detail-helper {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-helper-item {
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
}

.detail-helper-item strong {
  display: block;
  font-size: 0.76rem;
  margin-bottom: 2px;
}

.detail-helper-item span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.detail-secondary {
  margin-top: 16px;
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  overflow: hidden;
}

.detail-secondary summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 14px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.detail-secondary summary::-webkit-details-marker { display: none; }
.detail-secondary summary::after {
  content: "＋";
  color: var(--text-muted);
  flex-shrink: 0;
}
.detail-secondary[open] summary::after { content: "−"; }

.detail-secondary-body {
  padding: 0 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.detail-secondary-note {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 10px;
}

.detail-secondary-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.detail-secondary-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Score Card */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.detail-header .ticker-info h2 {
  font-size: 1.25rem;
  font-weight: 700;
}
.detail-header .stock-name {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.stock-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.header-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  border: 1px solid transparent;
}

.header-tag.main {
  color: #dcfce7;
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.28);
}

.header-tag.conditional {
  color: #dbeafe;
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.28);
}

.header-tag.support {
  color: #ede9fe;
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(139, 92, 246, 0.26);
}
.detail-header .price {
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Watch button */
.watch-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 1.3rem;
  padding: 8px 12px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.watch-btn:hover { border-color: var(--accent); color: var(--accent); }
.watch-btn.watched { color: #fbbf24; border-color: #fbbf2444; }

.early-status-panel {
  background: linear-gradient(180deg, rgba(19, 23, 34, 0.94), rgba(15, 17, 23, 0.98));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.early-status-panel.compact {
  margin-bottom: 16px;
}

.early-status-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.early-status-note {
  font-size: 0.82rem;
  font-weight: 700;
  color: #e5e7eb;
}

.early-status-progress {
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.early-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.early-status-pill.strong {
  color: #dcfce7;
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.early-status-pill.neutral {
  color: #fef3c7;
  background: rgba(234, 179, 8, 0.12);
  border: 1px solid rgba(234, 179, 8, 0.26);
}

.early-status-pill.caution {
  color: #fee2e2;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.early-status-reason {
  margin-top: 10px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-muted);
}

/* Circular Gauge */
.gauge-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 24px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.gauge-wrap {
  position: relative;
  width: 180px;
  height: 180px;
}

.gauge-svg {
  width: 180px;
  height: 180px;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.gauge-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease-out, stroke 0.4s;
}

.gauge-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.gauge-score {
  font-size: 2.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.gauge-label-badge {
  display: inline-block;
  padding: 2px 14px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 6px;
}

.monkey-index {
  font-size: 1.5rem;
  margin-top: 8px;
}

/* Trend badge */
.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 12px;
}
.trend-badge.up { background: #22c55e1a; color: var(--green); }
.trend-badge.down { background: #ef44441a; color: var(--red); }
.trend-badge.flat { background: #eab3081a; color: var(--yellow); }
.trend-arrow { font-size: 1rem; }

/* Label colors (PowerPro-like) */
.label-S { background: #ff4fa322; color: #ff4fa3; }
.label-A { background: #ff9f1c22; color: #ff9f1c; }
.label-B { background: #ffd60a22; color: #ffd60a; }
.label-C { background: #34c75922; color: #34c759; }
.label-D { background: #3b82f622; color: #3b82f6; }

.score-S { color: #ff4fa3; }
.score-A { color: #ff9f1c; }
.score-B { color: #ffd60a; }
.score-C { color: #34c759; }
.score-D { color: #3b82f6; }

.stroke-S { stroke: #ff4fa3; }
.stroke-A { stroke: #ff9f1c; }
.stroke-B { stroke: #ffd60a; }
.stroke-C { stroke: #34c759; }
.stroke-D { stroke: #3b82f6; }

/* Metrics Grid */
.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 14px;
  width: 100%;
  min-width: 0;
}
.metric {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  min-width: 0;
}
.metric .label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.metric .value {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.metric .value.metric-trend.trend-up,
.metric .value.metric-strong { color: #34c759; }
.metric .value.metric-trend.trend-down,
.metric .value.metric-weak { color: #3b82f6; }
.metric .value.metric-trend.trend-flat,
.metric .value.metric-neutral { color: #f3f4f6; }
.metric .value.metric-hot { color: #ff4fa3; }
.metric .value.metric-cool { color: #34c759; }

.detail-metrics-more {
  grid-column: 1 / -1;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}

.detail-metrics-more summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #d4d4d8;
}

.detail-metrics-more summary::-webkit-details-marker {
  display: none;
}

.detail-metrics-more summary::after {
  content: "＋";
  float: right;
  color: var(--text-muted);
}

.detail-metrics-more[open] summary::after {
  content: "−";
}

.detail-metrics-more-body {
  padding: 0 14px 14px;
}

.detail-metrics-more-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-metrics-more-item {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.04);
}

.detail-metrics-more-label {
  display: block;
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.detail-metrics-more-value {
  display: block;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

/* Flags */
.flags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.flag {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--border);
  color: var(--text-muted);
}
.flag.active { background: #6366f133; color: var(--accent); }
.flag.active.warn { background: #ef444433; color: var(--red); }

/* Chart area */
.chart-shell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.chart-head {
  margin-bottom: 8px;
  text-align: center;
}

.chart-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #eef2ff;
}

.chart-subtitle {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

.chart-axis-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 2px;
}

.chart-axis-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.chart-axis-label.left {
  color: #818cf8;
}

.chart-axis-label.right {
  color: #a1a1aa;
}

.chart-signal-perf {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 280px));
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
}

.signal-current-strip {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(23, 27, 39, 0.92), rgba(16, 18, 29, 0.98));
}

.signal-current-head {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.signal-current-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.signal-current-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}

.signal-current-chip.buy {
  border-color: rgba(34, 197, 94, 0.28);
  background: rgba(34, 197, 94, 0.08);
}

.signal-current-chip.sell {
  border-color: rgba(249, 115, 22, 0.28);
  background: rgba(249, 115, 22, 0.08);
}

.signal-current-chip.neutral {
  border-color: rgba(148, 163, 184, 0.24);
  background: rgba(148, 163, 184, 0.08);
}

.signal-current-chip-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: #f8fafc;
}

.signal-current-chip-date {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.signal-perf-chip {
  min-width: 0;
  width: min(280px, 100%);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(21, 25, 36, 0.92), rgba(17, 20, 30, 0.96));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.signal-perf-chip.buy {
  border-color: rgba(34, 197, 94, 0.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 0 0 1px rgba(34, 197, 94, 0.08);
}

.signal-perf-chip.sell {
  border-color: rgba(249, 115, 22, 0.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 0 0 1px rgba(249, 115, 22, 0.08);
}

.signal-perf-top {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

.signal-perf-headline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.signal-perf-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.signal-kind {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.signal-kind.buy {
  color: #dcfce7;
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid rgba(34, 197, 94, 0.32);
}

.signal-kind.sell {
  color: #ffedd5;
  background: rgba(249, 115, 22, 0.18);
  border: 1px solid rgba(249, 115, 22, 0.32);
}

.signal-kind.neutral {
  color: #e5e7eb;
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.26);
}

.signal-name {
  color: #f8fafc;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

.signal-perf-date {
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
  text-align: center;
}

.signal-entry-price {
  color: #e5e7eb;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.signal-perf-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
  text-align: center;
}

.signal-metric {
  padding: 6px 4px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.04);
}

.signal-metric-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  font-weight: 700;
}

.signal-metric-value {
  margin-top: 3px;
  font-size: 0.84rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.signal-metric-value.good { color: var(--green); }
.signal-metric-value.bad { color: var(--red); }
.signal-metric-value.neutral { color: var(--text-muted); }
.signal-metric-value.current { color: #f8fafc; }

.signal-perf-foot {
  margin-top: 7px;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.signal-perf-foot.good { color: var(--green); }
.signal-perf-foot.bad { color: var(--red); }
.signal-perf-foot.neutral { color: var(--text-muted); }

.chart-area {
  border-radius: 8px;
  padding: 2px 0 0;
  height: 200px;
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
.chart-area canvas { width: 100% !important; max-width: 100%; height: 100% !important; display: block; }

@media (max-width: 640px) {
  .container {
    padding: 12px 8px calc(96px + env(safe-area-inset-bottom));
  }

  .detail-helper {
    grid-template-columns: 1fr;
  }

  .detail-secondary-links {
    grid-template-columns: 1fr;
  }

  .detail-card {
    padding: 14px;
    border-radius: 10px;
  }

  .detail-header {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
  }

  .detail-header .ticker-info h2,
  .detail-header .price {
    font-size: 1.1rem;
  }

  .early-status-panel {
    padding: 12px;
    margin-bottom: 16px;
  }

  .early-status-top {
    flex-direction: column;
    gap: 8px;
  }

  .early-status-pill {
    min-width: 0;
  }

  .header-tag {
    font-size: 0.64rem;
    padding: 2px 7px;
  }

  .gauge-section {
    padding: 12px 0 18px;
    margin-bottom: 18px;
  }

  .gauge-wrap,
  .gauge-svg {
    width: 156px;
    height: 156px;
  }

  .gauge-score {
    font-size: 2.15rem;
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
  }

  .metric {
    padding: 10px 8px;
  }

  .metric .value {
    font-size: 1rem;
  }

  #d-signals {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px !important;
  }

  .flags {
    gap: 6px;
    margin-bottom: 16px;
  }

  .flag {
    font-size: 0.7rem;
    padding: 4px 8px;
  }

  .chart-shell {
    padding: 8px;
    border-radius: 10px;
  }

  .app-tabs {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }

  .app-tabs-inner {
    gap: 6px;
  }

  .app-tab {
    min-height: 50px;
    font-size: 0.68rem;
  }

  .detail-metrics-more {
    margin-bottom: 16px;
  }

  .detail-metrics-more summary {
    padding: 11px 12px;
    font-size: 0.76rem;
  }

  .detail-metrics-more-body {
    padding: 0 12px 12px;
  }

  .detail-metrics-more-grid {
    grid-template-columns: 1fr;
  }

  .chart-title {
    font-size: 1rem;
  }

  .chart-subtitle {
    font-size: 0.8rem;
  }

  .chart-axis-label {
    font-size: 0.66rem;
  }

  .chart-signal-perf {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-top: 8px;
  }

  .signal-current-strip {
    padding: 8px 10px;
  }

  .signal-current-chips {
    gap: 6px;
  }

  .signal-current-chip {
    width: 100%;
    justify-content: space-between;
    min-height: 34px;
    padding: 7px 9px;
  }

  .signal-current-chip-label {
    font-size: 0.76rem;
  }

  .signal-current-chip-date {
    font-size: 0.66rem;
  }

  .signal-perf-chip {
    width: 100%;
    padding: 8px;
  }

  .signal-perf-top {
    flex-direction: column;
    justify-content: center;
    font-size: 0.68rem;
  }

  .signal-name {
    font-size: 0.76rem;
  }

  .signal-entry-price {
    font-size: 0.68rem;
  }

  .signal-perf-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .signal-metric-value {
    font-size: 0.82rem;
  }

  .signal-perf-foot {
    font-size: 0.76rem;
  }

  .chart-area {
    padding: 2px 0 0;
    height: 248px;
  }
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.loading::after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.error {
  text-align: center;
  padding: 24px;
  color: var(--red);
  font-size: 0.9rem;
}

/* AI Analysis Section */
.ai-analysis-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.ai-analysis-btn {
  width: 100%;
  padding: 14px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
}
.ai-analysis-btn:active { background: var(--accent-hover); transform: scale(0.98); }
.ai-analysis-note {
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.5;
  text-align: center;
}
.ai-loading {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.ai-loading-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 8px;
  animation: ai-pulse 1s infinite;
}
@keyframes ai-pulse { 0%,100%{opacity:.3} 50%{opacity:1} }
.ai-error {
  padding: 12px;
  color: var(--red);
  font-size: 0.85rem;
  text-align: center;
}

/* Result Card */
.ai-result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.rpt-fold {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}

.rpt-fold summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #e5e7eb;
}

.rpt-fold summary::-webkit-details-marker {
  display: none;
}

.rpt-fold summary::after {
  content: "＋";
  float: right;
  color: var(--text-muted);
}

.rpt-fold[open] summary::after {
  content: "−";
}

.rpt-fold-body {
  padding: 0 14px 14px;
}

/* Hero Header (Rank + Action) */
.rpt-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  margin: -16px -16px 16px;
  border-radius: 14px 14px 0 0;
  background: var(--bg);
}
.rpt-hero-rank {
  font-size: 2rem;
  font-weight: 900;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  flex-shrink: 0;
}
.rpt-hero-rank.rank-S { background: #ff4fb322; color: #ff4fb3; }
.rpt-hero-rank.rank-A { background: #6366f122; color: var(--accent); }
.rpt-hero-rank.rank-B { background: #eab30822; color: var(--yellow); }
.rpt-hero-rank.rank-C { background: #71717a22; color: var(--text-muted); }
.rpt-hero-body { flex: 1; min-width: 0; }
.rpt-hero-action {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}
.rpt-hero-ev {
  font-size: 0.8rem;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.rpt-hero-ev.ev-plus { color: var(--green); }
.rpt-hero-ev.ev-minus { color: var(--red); }

/* Summary */
.rpt-summary {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text);
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.rpt-decision-card {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(15,23,42,0.2));
}

.rpt-decision-card.rank-S {
  border-color: rgba(255, 79, 179, 0.28);
  background: linear-gradient(135deg, rgba(255,79,179,0.16), rgba(99,102,241,0.14));
}

.rpt-decision-card.rank-A {
  border-color: rgba(99, 102, 241, 0.28);
}

.rpt-decision-card.rank-B {
  border-color: rgba(234, 179, 8, 0.25);
  background: linear-gradient(135deg, rgba(234,179,8,0.14), rgba(15,23,42,0.2));
}

.rpt-decision-kicker {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #c7d2fe;
  text-transform: uppercase;
}

.rpt-decision-title {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 800;
  color: #f8fafc;
}

.rpt-decision-text {
  margin-top: 6px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #e5e7eb;
}

.rpt-decision-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.rpt-decision-item {
  padding: 10px;
  border-radius: 10px;
  background: rgba(15,17,23,0.36);
  border: 1px solid rgba(255,255,255,0.05);
}

.rpt-decision-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.rpt-decision-value {
  font-size: 0.9rem;
  font-weight: 800;
  color: #f8fafc;
}

.rpt-decision-sub {
  margin-top: 4px;
  font-size: 0.74rem;
  line-height: 1.5;
  color: #d4d4d8;
}

/* Sections (numbered) */
.rpt-section {
  display: flex;
  gap: 10px;
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.rpt-section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.rpt-section-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.rpt-section-content { flex: 1; min-width: 0; }
.rpt-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

/* Key-Value pairs */
.rpt-kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  gap: 8px;
}
.rpt-k {
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
  font-size: 0.75rem;
}
.rpt-v {
  text-align: right;
  color: var(--text);
  word-break: break-word;
}
.rpt-text-sm {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 4px 0 6px;
}

/* Pills */
.rpt-pill-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0;
}
.rpt-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.rpt-pill.pattern { background: #6366f122; color: var(--accent); }
.rpt-pill.stag-完了 { background: #22c55e22; color: var(--green); }
.rpt-pill.stag-形成中 { background: #eab30822; color: var(--yellow); }
.rpt-pill.stag-未形成 { background: #71717a22; color: var(--text-muted); }

/* Strategy Grid */
.rpt-strategy-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.rpt-strategy-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid transparent;
}
.rpt-strategy-hero.rank-S {
  background: linear-gradient(135deg, rgba(255, 79, 179, 0.18), rgba(99, 102, 241, 0.12));
  border-color: rgba(255, 79, 179, 0.28);
}
.rpt-strategy-hero.rank-A {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(59, 130, 246, 0.12));
  border-color: rgba(99, 102, 241, 0.3);
}
.rpt-strategy-hero.rank-B {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.18), rgba(249, 115, 22, 0.12));
  border-color: rgba(234, 179, 8, 0.28);
}
.rpt-strategy-hero.rank-C {
  background: linear-gradient(135deg, rgba(113, 113, 122, 0.22), rgba(63, 63, 70, 0.12));
  border-color: rgba(113, 113, 122, 0.3);
}
.rpt-strategy-rank {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 900;
  color: #fff;
  background: rgba(15, 17, 23, 0.35);
}
.rpt-strategy-main {
  min-width: 0;
}
.rpt-strategy-action {
  font-size: 1rem;
  font-weight: 800;
  color: #f8fafc;
}
.rpt-strategy-sub {
  margin-top: 2px;
  font-size: 0.74rem;
  color: #e5e7eb;
}
.rpt-sg-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}
.rpt-sg-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}
.rpt-sg-value {
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Advice */
.rpt-advice {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

.rpt-mini-fold {
  margin-top: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}

.rpt-mini-fold summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
}

.rpt-mini-fold summary::-webkit-details-marker {
  display: none;
}

.rpt-mini-fold summary::after {
  content: "＋";
  float: right;
  color: var(--text-muted);
}

.rpt-mini-fold[open] summary::after {
  content: "−";
}

.rpt-mini-fold-body {
  padding: 0 12px 12px;
}

@media (max-width: 640px) {
  .rpt-decision-grid {
    grid-template-columns: 1fr;
  }
}

/* Inline Charts */
.inline-chart-wrap {
  margin-top: 10px;
}
.inline-chart-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.inline-chart-box {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px;
  height: 180px;
  position: relative;
}
.inline-chart-box canvas { width: 100%; height: 100%; }
.inline-chart-empty {
  display: grid;
  place-items: center;
  height: 100%;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.5;
}

/* Caution */
.ai-caution {
  font-size: 0.78rem;
  color: var(--yellow);
  background: #eab30810;
  border: 1px solid #eab30833;
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 12px;
  line-height: 1.5;
}

/* Disclaimer */
.ai-disclaimer {
  margin-top: 14px;
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.5;
}

/* MTF Trend Bar (月足→週足→日足) */
.mtf-trend-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.mtf-chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.mtf-chart-card {
  min-width: 0;
}
.mtf-trend-item {
  flex: 1;
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
}
.mtf-inline-box {
  height: 168px;
  margin-top: 6px;
}
.mtf-trend-tf {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.mtf-trend-dir {
  font-size: 0.82rem;
  font-weight: 700;
  margin-top: 2px;
}
.mtf-trend-dir.trend-up { color: var(--green); }
.mtf-trend-dir.trend-down { color: var(--red); }
.mtf-trend-dir.trend-range { color: var(--yellow); }
.mtf-trend-note {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.ai-source-note {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.5;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .container { padding: 16px 12px; }
  .detail-back { font-size: 0.78rem; }
  .rpt-hero { padding: 12px; gap: 12px; margin: -16px -16px 14px; }
  .rpt-hero-rank { width: 48px; height: 48px; font-size: 1.7rem; }
  .rpt-hero-action { font-size: 1rem; }
  .rpt-section { gap: 8px; }
  .rpt-section-num { width: 22px; height: 22px; font-size: 0.65rem; }
  .inline-chart-box { height: 150px; padding: 6px; }
  .mtf-chart-grid { grid-template-columns: 1fr; gap: 10px; }
  .mtf-inline-box { height: 182px; }
  .rpt-strategy-hero { padding: 10px 12px; gap: 10px; }
  .rpt-strategy-rank { width: 42px; height: 42px; font-size: 1.15rem; }
  .rpt-strategy-action { font-size: 0.92rem; }
  .rpt-strategy-grid { gap: 4px; }
  .rpt-sg-item { padding: 6px 8px; }
  .mtf-trend-item { padding: 6px 4px; }
  .mtf-trend-dir { font-size: 0.78rem; }
  /* KV縦スタック（長いテキストが折り返せるように） */
  .rpt-kv {
    flex-direction: column;
    gap: 1px;
    align-items: flex-start;
  }
  .rpt-v {
    text-align: left;
    font-size: 0.82rem;
    padding-left: 0;
  }
  .rpt-text-sm { font-size: 0.76rem; }
  .rpt-summary { font-size: 0.84rem; line-height: 1.65; }
  .ai-result-card { padding: 14px; }
  .rpt-fold summary {
    padding: 11px 12px;
    font-size: 0.78rem;
  }
  .rpt-fold-body {
    padding: 0 12px 12px;
  }
  .ai-caution { font-size: 0.76rem; padding: 8px 10px; }
  .ai-disclaimer { font-size: 0.55rem; }
}
