:root {
  --bg: #0a0d12;
  --bg-elevated: #0f141a;
  --surface: #131920;
  --surface-raised: #1a222b;
  --border: #232c37;
  --border-strong: #333f4d;
  --text: #edf1f5;
  --text-muted: #8f9aa9;
  --text-faint: #66717f;

  --accent: #e8b84b;
  --accent-dim: rgba(232, 184, 75, 0.14);

  --buy: #34d399;
  --buy-bg: rgba(52, 211, 153, 0.12);
  --sell: #f0625f;
  --sell-bg: rgba(240, 98, 95, 0.13);
  --hold: #9aa4b2;
  --hold-bg: rgba(154, 164, 178, 0.12);

  --risk-low: #34d399;
  --risk-low-bg: rgba(52, 211, 153, 0.12);
  --risk-medium: #e8b84b;
  --risk-medium-bg: rgba(232, 184, 75, 0.12);
  --risk-high: #f0625f;
  --risk-high-bg: rgba(240, 98, 95, 0.13);

  /* グラスモーフィズム用トークン */
  --glass-bg: rgba(255, 255, 255, 0.045);
  --glass-bg-strong: rgba(255, 255, 255, 0.075);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-border-gold: rgba(232, 184, 75, 0.28);
  --glass-blur: 16px;
  --glass-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;

  --font-ui: "Inter", -apple-system, "Hiragino Kaku Gothic ProN", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-padding-top: 72px;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background:
    radial-gradient(1100px 560px at 8% -8%, rgba(232, 184, 75, 0.11), transparent 62%),
    radial-gradient(900px 520px at 100% 4%, rgba(96, 124, 255, 0.08), transparent 58%),
    radial-gradient(800px 500px at 50% 110%, rgba(232, 184, 75, 0.06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
}

a {
  color: inherit;
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---- グラス面(共通コンポーネント) ----
   カード・フォーム・チャート・モーダル等、「面」になる要素はすべてここで質感を揃える。 */

.glass,
.disclaimer,
.no-data,
.alert-calm,
.stats-strip,
.rank-card,
.holding-card,
.trade-card,
.eval-block,
.chart-wrap,
.trade-form,
.perf-cell,
.eval-timeline-item,
.eval-compare {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  backdrop-filter: blur(var(--glass-blur)) saturate(140%);
  box-shadow: var(--glass-shadow);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass,
  .disclaimer,
  .no-data,
  .alert-calm,
  .stats-strip,
  .rank-card,
  .holding-card,
  .trade-card,
  .eval-block,
  .chart-wrap,
  .trade-form,
  .perf-cell,
  .eval-timeline-item,
  .eval-compare {
    background: var(--surface);
  }
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(10, 13, 18, 0.62);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid var(--glass-border);
}

.app-header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: 0 0 auto;
}

.brand-mark {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.78em;
  letter-spacing: 0.02em;
  color: #1a1200;
  background: linear-gradient(135deg, #f3cf7a, var(--accent));
  border-radius: 6px;
  padding: 3px 7px;
  box-shadow: 0 0 14px rgba(232, 184, 75, 0.35);
}

.brand-text {
  font-weight: 700;
  font-size: 1.02em;
  color: var(--text);
  white-space: nowrap;
}

.top-nav {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
}

.top-nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.92em;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
}

.top-nav-link:hover {
  color: var(--text);
  background: var(--glass-bg-strong);
}

.top-nav-link.active {
  color: #1a1200;
  background: linear-gradient(135deg, #f3cf7a, var(--accent));
}

.header-meta {
  flex: 0 0 auto;
  font-size: 0.78em;
  color: var(--text-faint);
  text-align: right;
  max-width: 260px;
}

/* ---- メイン・共通 ---- */

.app-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

.disclaimer {
  font-size: 0.76em;
  color: var(--text-faint);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 0 24px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 32px 0 6px;
}

.section-head:first-of-type {
  margin-top: 0;
}

.section-head h2 {
  font-size: 1.08em;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.section-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-label {
  font-size: 0.78em;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.toggle-label input {
  accent-color: var(--accent);
}

.section-note {
  font-size: 0.82em;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.text-link {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.ghost-button,
.primary-button,
.danger-button,
.small-button {
  font-family: var(--font-ui);
  font-size: 0.85em;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ghost-button:hover,
.small-button:hover {
  background: var(--glass-bg-strong);
  border-color: var(--glass-border-gold);
}

.primary-button {
  border: none;
  background: linear-gradient(135deg, #f3cf7a, var(--accent));
  color: #1a1200;
  padding: 12px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(232, 184, 75, 0.25);
}

.primary-button:hover {
  filter: brightness(1.06);
}

.danger-button {
  border: 1px solid rgba(240, 98, 95, 0.5);
  background: rgba(240, 98, 95, 0.16);
  color: #ff8d8a;
  padding: 10px 18px;
  font-weight: 700;
}

.danger-button:hover {
  background: rgba(240, 98, 95, 0.26);
}

.small-button {
  font-size: 0.78em;
  padding: 6px 12px;
}

.small-button.sell-action {
  color: var(--sell);
  border-color: rgba(240, 98, 95, 0.45);
}

.small-button.cancel-action {
  color: var(--text-muted);
}

.text-button {
  align-self: flex-start;
  font-family: var(--font-ui);
  font-size: 0.74em;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.primary-button:disabled,
.danger-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.back-button {
  margin-bottom: 18px;
}

.no-data {
  color: var(--text-muted);
  font-size: 0.9em;
  border-style: dashed;
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
}

/* ---- バッジ ---- */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.74em;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-buy { color: var(--buy); background: var(--buy-bg); }
.badge-hold { color: var(--hold); background: var(--hold-bg); }
.badge-sell { color: var(--sell); background: var(--sell-bg); }

.badge-risk-low { color: var(--risk-low); background: var(--risk-low-bg); }
.badge-risk-medium { color: var(--risk-medium); background: var(--risk-medium-bg); }
.badge-risk-high { color: var(--risk-high); background: var(--risk-high-bg); }

.badge-soft {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.07);
}

.badge-gold {
  color: var(--accent);
  background: var(--accent-dim);
}

.badge-win { color: var(--buy); background: var(--buy-bg); }
.badge-lose { color: var(--sell); background: var(--sell-bg); }
.badge-even { color: var(--hold); background: var(--hold-bg); }

.positive { color: var(--buy); }
.negative { color: var(--sell); }

/* ---- 今すぐ確認ゾーン(ホーム) ---- */

.alert-zone {
  margin-bottom: 28px;
}

.alert-zone-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.alert-zone-head h2 {
  font-size: 1.05em;
  font-weight: 700;
  margin: 0;
}

.alert-count {
  font-family: var(--font-mono);
  font-size: 0.75em;
  font-weight: 700;
  color: var(--sell);
  background: var(--sell-bg);
  border-radius: 999px;
  padding: 2px 9px;
}

.alert-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: linear-gradient(135deg, rgba(240, 98, 95, 0.12), rgba(255, 255, 255, 0.04) 60%);
  border: 1px solid rgba(240, 98, 95, 0.35);
  border-left: 3px solid var(--sell);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
}

.alert-card:hover {
  border-color: rgba(240, 98, 95, 0.55);
}

.alert-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.alert-reason {
  font-size: 0.85em;
  color: var(--text-muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.alert-calm {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.92em;
}

.alert-calm-icon {
  color: var(--buy);
  font-size: 1.2em;
}

/* ---- 統計ストリップ(ホーム) ---- */

.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}

.stat-cell {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
}

.stat-label {
  font-size: 0.72em;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.25em;
  font-weight: 700;
}

/* ---- カードグリッド(ランキング等) ---- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
  /* Gridアイテムは既定でmin-width:autoのため、子要素に長い改行不可能なテキストが
     含まれると、このグリッド自体がビューポート幅を超えて広がり、
     モバイルブラウザがページ全体を縮小表示してしまうことがある。
     子アイテム(.rank-card等)側に個別でmin-width:0を指定して対処する。 */
  min-width: 0;
}

.rank-card {
  display: block;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
  padding: 15px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.rank-card:hover {
  border-color: var(--glass-border-gold);
  transform: translateY(-1px);
}

.rank-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}

.rank-number {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.72em;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rank-card-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.stock-code {
  font-family: var(--font-mono);
  font-size: 0.74em;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.stock-name {
  font-weight: 700;
  font-size: 0.98em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-score {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 1.3em;
  font-weight: 700;
  color: var(--accent);
}

.ai-score small {
  font-size: 0.5em;
  font-weight: 500;
  color: var(--text-faint);
}

.rank-card-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 11px;
}

.rank-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 9px;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.metric-label {
  font-size: 0.68em;
  color: var(--text-faint);
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-weight: 700;
}

.rank-card-summary {
  font-size: 0.83em;
  color: var(--text-muted);
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-line {
  font-size: 0.7em;
  color: var(--text-faint);
}

/* ---- 保有銘柄カード ---- */

.holding-card {
  display: block;
  min-width: 0;
  color: inherit;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}

.holding-card:hover {
  border-color: var(--glass-border-gold);
}

.holding-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.holding-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.holding-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.holding-badge-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.holding-acquired-date {
  white-space: nowrap;
}

.holding-pnl {
  text-align: right;
  flex: 0 0 auto;
}

.holding-pnl-value {
  font-family: var(--font-mono);
  font-size: 1.15em;
  font-weight: 700;
}

.holding-pnl-pct {
  font-family: var(--font-mono);
  font-size: 0.78em;
}

.holding-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 10px;
}

.holding-action-hint {
  font-size: 0.85em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.holding-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.action-hint-sell { color: var(--sell); font-weight: 700; }
.action-hint-hold { color: var(--hold); font-weight: 700; }
.action-hint-buy { color: var(--buy); font-weight: 700; }

/* 保有銘柄カード内のAI評価の変化 */

.eval-change {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--glass-border);
}

.eval-change-title {
  font-size: 0.7em;
  color: var(--text-faint);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.eval-change-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.eval-step {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.eval-step-label {
  font-size: 0.66em;
  color: var(--text-faint);
}

.eval-step-body {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-weight: 700;
}

.eval-change-summary {
  margin-top: 8px;
  font-size: 0.76em;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.delta-up { color: var(--buy); font-weight: 700; }
.delta-down { color: var(--sell); font-weight: 700; }
.delta-flat { color: var(--text-muted); font-weight: 700; }

/* ---- 売買履歴カード ---- */

.trade-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border-radius: var(--radius);
  padding: 13px 15px;
  margin-bottom: 8px;
  color: inherit;
}

.trade-card.canceled {
  opacity: 0.55;
  border-style: dashed;
}

.trade-card.canceled .trade-card-pnl-value,
.trade-card.canceled .stock-name {
  text-decoration: line-through;
}

.trade-type-flag {
  font-family: var(--font-mono);
  font-size: 0.72em;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.trade-type-flag.buy { color: var(--buy); background: var(--buy-bg); }
.trade-type-flag.sell { color: var(--sell); background: var(--sell-bg); }

.trade-card-main {
  min-width: 0;
}

.trade-card-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}

.trade-card-title a {
  text-decoration: none;
}

.trade-card-sub {
  font-size: 0.78em;
  color: var(--text-muted);
  display: flex;
  gap: 4px 12px;
  flex-wrap: wrap;
}

.trade-card-pnl {
  text-align: right;
  flex: 0 0 auto;
}

.trade-card-pnl-value {
  font-family: var(--font-mono);
  font-weight: 700;
}

.trade-card-pnl-label {
  font-size: 0.68em;
  color: var(--text-faint);
}

.trade-card-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  align-items: center;
}

/* ---- 通算成績 ---- */

.perf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.perf-cell {
  border-radius: var(--radius);
  padding: 13px 15px;
  min-width: 0;
}

.perf-cell.highlight {
  border-color: var(--glass-border-gold);
  background: linear-gradient(135deg, rgba(232, 184, 75, 0.12), var(--glass-bg) 65%);
}

.perf-label {
  font-size: 0.7em;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.perf-value {
  font-family: var(--font-mono);
  font-size: 1.2em;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.perf-sub {
  font-size: 0.7em;
  color: var(--text-faint);
  margin-top: 2px;
}

/* ---- 詳細画面 ---- */

.detail-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.detail-header .stock-name {
  font-size: 1.3em;
}

.market-tag {
  font-size: 0.72em;
  color: var(--text-muted);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 2px 10px;
}

.current-price-line {
  font-size: 1em;
  margin-bottom: 22px;
  color: var(--text-muted);
}

.current-price-line strong {
  font-family: var(--font-mono);
  font-size: 1.35em;
  color: var(--text);
}

.detail-subhead {
  font-size: 1em;
  font-weight: 700;
  margin: 24px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--glass-border);
}

.chart-wrap {
  border-radius: var(--radius);
  padding: 10px 4px 8px;
}

.price-chart,
.cum-chart,
.score-chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-gridline {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.chart-zero-line {
  stroke: rgba(232, 184, 75, 0.45);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.chart-axis-label {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--text-faint);
}

.chart-line {
  stroke: var(--hold);
  stroke-width: 2;
}

.price-chart.positive .chart-line { stroke: var(--buy); }
.price-chart.negative .chart-line { stroke: var(--sell); }

.chart-last-point { fill: currentColor; }
.price-chart.positive .chart-last-point { fill: var(--buy); }
.price-chart.negative .chart-last-point { fill: var(--sell); }

.cum-chart .chart-line,
.score-chart .chart-line {
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linejoin: round;
}

.cum-chart .chart-area {
  fill: url(#cum-gradient);
}

.cum-chart .chart-point {
  fill: var(--accent);
  stroke: rgba(10, 13, 18, 0.9);
  stroke-width: 1.5;
}

.cum-chart .chart-point.win { fill: var(--buy); }
.cum-chart .chart-point.lose { fill: var(--sell); }

.score-chart .chart-point {
  fill: var(--accent);
}

.chart-range-note {
  font-size: 0.72em;
  color: var(--text-faint);
  text-align: center;
  padding: 2px 0 4px;
}

.eval-block {
  border-radius: var(--radius);
  padding: 18px;
}

.eval-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.eval-top .ai-score {
  margin-left: auto;
  font-size: 1.5em;
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 14px;
}

.eval-summary {
  font-size: 0.95em;
  margin: 0 0 10px;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.eval-reasoning {
  font-size: 0.85em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.eval-reasoning summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.eval-reasoning p {
  margin: 8px 0 0;
}

/* AI評価履歴 */

.eval-compare {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  font-size: 0.88em;
}

.eval-compare-arrow {
  color: var(--text-faint);
}

.eval-timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.eval-timeline-item {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border-radius: var(--radius);
  padding: 11px 14px;
}

.eval-timeline-item.purchase {
  border-color: var(--glass-border-gold);
  box-shadow: var(--glass-shadow), 0 0 0 1px rgba(232, 184, 75, 0.12);
}

.eval-timeline-when {
  min-width: 0;
  font-size: 0.78em;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.eval-timeline-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.eval-timeline-main {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eval-timeline-metrics {
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--text-muted);
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ---- 売買登録フォーム ---- */

.trade-form {
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 32px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
  align-items: end;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-row label {
  font-size: 0.76em;
  color: var(--text-muted);
}

.form-row input,
.form-row select {
  font-family: var(--font-ui);
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 0.95em;
}

.form-row input:focus,
.form-row select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ダーク背景だとブラウザ既定のカレンダーアイコンが黒っぽく表示され見えなくなるため、
   明るく反転させて視認・クリックできるようにする(Chrome/Edge等のChromium系ブラウザ向け)。 */
.form-row input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
  cursor: pointer;
  border-radius: 4px;
}

.form-row input[type="date"]::-webkit-calendar-picker-indicator:hover {
  background: var(--surface-raised);
}

.trade-form button[type="submit"] {
  grid-column: 1 / -1;
  justify-self: start;
  min-width: 140px;
}

.form-message {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.85em;
  min-height: 0;
}

.form-message:empty {
  display: none;
}

.form-message-success { color: var(--buy); }
.form-message-error { color: var(--sell); }

/* ---- モーダル ---- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.66);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 20px;
  background: rgba(22, 28, 36, 0.78);
  border: 1px solid var(--glass-border-gold);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.modal-head h3 {
  margin: 0;
  font-size: 1.05em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5em;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.modal-close:hover {
  color: var(--text);
}

.modal-info {
  font-size: 0.88em;
  margin-bottom: 14px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--glass-border);
}

.info-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-preview {
  font-size: 0.82em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(232, 184, 75, 0.07);
  border: 1px solid rgba(232, 184, 75, 0.2);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.modal-actions .primary-button {
  padding: 10px 18px;
}

.modal-warning {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84em;
  color: #ffb4b2;
  background: rgba(240, 98, 95, 0.1);
  border: 1px solid rgba(240, 98, 95, 0.3);
}

.modal-warning.neutral {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--glass-border);
}

/* ---- フッター・下部ナビ ---- */

.app-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 88px;
  font-size: 0.74em;
  color: var(--text-faint);
  border-top: 1px solid var(--glass-border);
  padding-top: 14px;
}

.bottom-nav {
  display: none;
}

/* ---- レスポンシブ ---- */

@media (max-width: 860px) {
  .top-nav {
    display: none;
  }
  .header-meta {
    display: none;
  }
  .app-header-inner {
    padding: 12px 16px;
  }
  .app-main {
    padding: 16px 14px 24px;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: rgba(12, 16, 22, 0.72);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
    border-top: 1px solid var(--glass-border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }

  .bottom-nav-link {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-faint);
    font-size: 0.68em;
    padding: 6px 2px;
    border-radius: var(--radius-sm);
  }

  .bottom-nav-link.active {
    color: var(--accent);
  }

  .bottom-nav-icon {
    font-size: 1.2em;
  }

  .app-footer {
    padding-bottom: 96px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .rank-card-metrics,
  .detail-metrics {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .holding-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .trade-card {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 8px;
  }

  .trade-card-pnl {
    grid-column: 1 / -1;
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
  }

  .trade-card-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin-top: 0;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .eval-change-row {
    grid-template-columns: 1fr;
  }

  .eval-timeline-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .eval-timeline-metrics {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    text-align: left;
  }

  .section-head {
    flex-wrap: wrap;
  }
}

@media (max-width: 420px) {
  .holding-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-dialog {
    padding: 16px;
  }
}

/* ---- SBI発注補助(BUY/SELL) ---- */

.rank-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.rank-card-actions,
.assist-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rank-card-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--glass-border);
}

.assist-cta {
  margin-bottom: 12px;
}

.assist-note {
  font-size: 0.74em;
  color: var(--text-faint);
  margin: 8px 0 0;
  line-height: 1.55;
}

.assist-error {
  font-size: 0.86em;
  color: #ffb4b2;
  background: rgba(240, 98, 95, 0.1);
  border: 1px solid rgba(240, 98, 95, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

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

.assist-tiles.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.assist-tile {
  min-width: 0;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
}

.assist-tile.primary {
  border-color: var(--glass-border-gold);
  background: linear-gradient(135deg, rgba(232, 184, 75, 0.14), rgba(255, 255, 255, 0.04) 70%);
}

.assist-tile-label {
  font-size: 0.68em;
  color: var(--text-faint);
  margin-bottom: 3px;
}

.assist-tile-value {
  font-size: 1.12em;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.assist-order {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid var(--glass-border-gold);
}

.assist-order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.84em;
  font-weight: 700;
  color: var(--accent);
}

.assist-order-list {
  margin: 0;
  display: grid;
  gap: 6px;
}

.assist-order-row {
  display: grid;
  grid-template-columns: 6.5em minmax(0, 1fr);
  gap: 8px;
  font-size: 0.9em;
}

.assist-order-row dt {
  color: var(--text-muted);
}

.assist-order-row dd {
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.assist-register-head {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--glass-border);
  font-size: 0.78em;
  color: var(--text-muted);
  font-weight: 700;
}

@media (max-width: 420px) {
  .assist-tiles.three .assist-tile-value {
    font-size: 0.98em;
  }
}

.small-button.buy-action {
  color: var(--buy);
  border-color: rgba(52, 211, 153, 0.45);
  min-width: 72px;
}

/* ---- 未完了取引の状況(保有銘柄画面) ----
   保有中・未売却の取引だけの集計とグラフ。既存のダーク×ゴールドの配色(--buy / --sell / --accent)に合わせる。 */

.open-positions {
  margin-bottom: 28px;
}

.open-positions .section-head h3 {
  margin: 0;
  font-size: 1.05em;
}

.op-summary {
  margin-bottom: 12px;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}

.stat-sub {
  margin-top: 4px;
  font-size: 0.68em;
  color: var(--text-faint);
  line-height: 1.4;
}

.op-na {
  font-family: inherit;
  font-size: 0.8em;
  font-weight: 600;
  color: var(--text-muted);
}

.op-caveat {
  margin: 0 0 8px;
  padding: 8px 12px;
  font-size: 0.8em;
  line-height: 1.55;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: var(--radius);
}

.op-meta {
  margin: 0 0 6px;
  font-size: 0.78em;
  color: var(--text-muted);
}

.op-chart-title {
  margin: 20px 0 8px;
  font-size: 0.9em;
  font-weight: 600;
  color: var(--text);
}

.op-chart {
  /* グラフはスマートフォン幅(約360px)を基準に描いている。PCで引き伸ばしすぎると文字が大きくなるため、上限を決める */
  max-width: 440px;
}

.oc-svg {
  display: block;
  width: 100%;
  height: auto;
}

.oc-label {
  font-size: 11px;
  fill: var(--text-muted);
}

.oc-value {
  font-size: 10.5px;
  font-family: var(--font-mono);
  fill: var(--text);
}

.oc-value.positive {
  fill: var(--buy);
}

.oc-value.negative {
  fill: var(--sell);
}

.oc-na-text {
  font-size: 10.5px;
  fill: var(--text-faint);
}

.oc-bar-cost {
  fill: var(--text-faint);
  background: var(--text-faint);
}

.oc-bar-value {
  fill: var(--accent);
  background: var(--accent);
}

.oc-pos {
  fill: var(--buy);
}

.oc-neg {
  fill: var(--sell);
}

.oc-axis {
  stroke: var(--border-strong);
  stroke-width: 1;
}

.oc-legend-inline {
  display: flex;
  gap: 16px;
  margin-bottom: 6px;
  font-size: 0.78em;
  color: var(--text-muted);
}

.oc-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: -1px;
}

.oc-stack {
  margin-bottom: 10px;
}

.oc-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.82em;
}

.oc-legend li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: baseline;
  gap: 6px 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}

.oc-legend-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.oc-legend-pct {
  color: var(--text-muted);
}

.oc-legend-amt {
  min-width: 78px;
  text-align: right;
  color: var(--text);
}

.op-table-wrap {
  overflow-x: auto;
}

.op-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
}

.op-table th,
.op-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.op-table th:first-child,
.op-table td:first-child {
  text-align: left;
  white-space: normal;
}

.op-table th {
  font-size: 0.78em;
  font-weight: 600;
  color: var(--text-faint);
}

/* スマートフォン: 表を、銘柄ごとのカード(項目名 + 値)に並べ替える */
@media (max-width: 640px) {
  .op-table thead {
    display: none;
  }

  .op-table,
  .op-table tbody,
  .op-table tr,
  .op-table td {
    display: block;
    width: 100%;
  }

  .op-table tr {
    margin-bottom: 10px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .op-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border-bottom: none;
    text-align: right;
    white-space: normal;
  }

  .op-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--text-faint);
    font-size: 0.85em;
    text-align: left;
  }

  .op-table td:first-child {
    justify-content: flex-start;
    font-weight: 600;
  }

  .op-table td:first-child::before {
    content: none;
  }
}
