/**
 * Expect ～ KEIBA AI ～
 * Mockup-faithful styles (home canvas first)
 */

@import url("./components/mascot.css");

:root {
  --bg: #080c12;
  --bg-2: #0d121a;
  --card: #141820;
  --card-2: #171c26;
  --ink: #ffffff;
  --muted: #9aa0ab;
  --gold: #c1a26d;
  --gold-soft: #d4b37d;
  --gold-deep: #8c6e42;
  --line: rgba(193, 162, 109, 0.28);
  --good: rgba(40, 90, 55, 0.55);
  --radius: 16px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --pad: 16px;
  --app-max: 430px;
  --max: var(--app-max);
  --nav-h: 64px;
  --font: "Noto Sans JP", "Hiragino Sans", "Segoe UI", Meiryo, sans-serif;
  --display: "Cormorant Garamond", "Times New Roman", Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", monospace;
  --accent: var(--gold);
  --accent-soft: rgba(193, 162, 109, 0.14);
  --surface: rgba(255, 255, 255, 0.04);
  --honmei: #e8b4a0;
  --warn: #d4a24c;
  --danger: #c07070;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: #05070c;
  line-height: 1.45;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }

.app {
  --app-max: var(--max);
  /* flex子の min-width:auto でヒートマップ等が親を押し広げないようにする */
  flex: 0 1 auto;
  width: min(100%, var(--max));
  max-width: var(--max);
  min-width: 0;
  margin: 0 auto;
  min-height: 100%;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(193, 162, 109, 0.08), transparent 55%),
    linear-gradient(180deg, #0b1018 0%, var(--bg) 40%, #070a10 100%);
  position: relative;
  overflow-x: hidden;
  box-sizing: border-box;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  /* fixed ではなく absolute 基準の包含ブロックにする */
  isolation: isolate;
}

/* ========== Header ========== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(8, 12, 18, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px var(--pad) 8px;
}

.topbar-left {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.brand-name {
  margin: 0;
  font-family: var(--display);
  font-size: 34px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  color: #fff;
}

.brand-sub {
  margin: 4px 0 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--gold);
  font-weight: 500;
}

/* JS用タイトルはホームでは見せない */
.page-home .page-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.is-catalog-view .page-title {
  position: static;
  width: auto;
  height: auto;
  clip: auto;
  overflow: visible;
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.topbar-tools {
  display: flex;
  gap: 10px;
  padding-top: 6px;
}

.icon-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--gold-soft);
}

.icon-btn .nav-ico {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  color: inherit;
}

.icon-btn img {
  width: 22px;
  height: 22px;
  filter: none;
}

.back-btn {
  width: 32px;
  height: 32px;
  margin-top: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--gold-soft);
  font-size: 22px;
  line-height: 1;
  flex: 0 0 auto;
  text-decoration: none;
}

.back-btn[hidden] { display: none; }
a.back-btn { color: var(--gold-soft); }

/* ========== Home chrome ========== */
.home-chrome {
  padding: 4px var(--pad) 28px;
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

.home-chrome[hidden] { display: none; }

.home-chrome > * {
  min-width: 0;
  max-width: 100%;
}

.home-date {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
}

/* 上: 統計 / 下: お気に入り */
.dash-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.dash-stats {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 12px 16px;
  padding: 2px 2px 0;
  min-width: 0;
  min-height: 88px;
}

.dash-time {
  position: absolute;
  left: 34%;
  bottom: 18px;
  transform: translateX(-50%);
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(64px, 20vw, 92px);
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: 0.02em;
  color: #fff;
  pointer-events: none;
}

.dash-metrics {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
  min-width: 0;
  flex: 0 0 auto;
  padding-bottom: 4px;
}

.dash-metric {
  min-width: 0;
  text-align: right;
}

.dash-label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.88);
}

.info-ico {
  width: 12px;
  height: 12px;
  opacity: 0.85;
  display: inline-block;
}

.dash-roi {
  margin: 2px 0 0;
  font-family: var(--display);
  font-size: clamp(28px, 8vw, 38px);
  font-weight: 600;
  line-height: 1;
  color: var(--gold-soft);
  text-align: right;
}

.dash-rank {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--gold);
  font-weight: 500;
  text-align: right;
}

.dash-rank span { font-size: 13px; }

/* 旧クラス互換 */
.dash-row { display: contents; }
.dash-rule { display: none; }

.fav-panel {
  background: var(--card);
  border: 1px solid rgba(193, 162, 109, 0.18);
  border-radius: var(--radius);
  padding: 10px 10px 10px;
  min-width: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.fav-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.fav-panel-title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.fav-panel-title .star {
  color: var(--gold);
  font-size: 13px;
}

.fav-edit {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
}

.favorites-rail {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px;
  cursor: grab;
  user-select: none;
}

.favorites-rail::-webkit-scrollbar { display: none; height: 0; }

.favorites-rail.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
  scroll-behavior: auto;
}

.fav-card {
  position: relative;
  flex: 0 0 132px;
  scroll-snap-align: start;
  border-radius: 12px;
  overflow: hidden;
  background-color: #10151d;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(193, 162, 109, 0.22);
  display: flex;
  flex-direction: column;
  min-height: 148px;
  touch-action: pan-x;
  isolation: isolate;
}

.fav-card-shade {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(8, 10, 14, 0.55) 0%, rgba(8, 10, 14, 0.78) 48%, rgba(8, 10, 14, 0.9) 100%);
  pointer-events: none;
}

.fav-card-text {
  position: relative;
  z-index: 1;
  padding: 10px 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.fav-meta {
  margin: 0;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.fav-place {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.fav-name {
  margin: 2px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.fav-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffe7a8;
  border: 1px solid rgba(193, 162, 109, 0.55);
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(0, 0, 0, 0.45);
}

.fav-card-photo {
  display: none;
}

.fav-empty {
  flex: 1 0 100%;
  min-height: 88px;
  display: grid;
  place-items: center;
  padding: 16px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(193, 162, 109, 0.35);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  box-sizing: border-box;
}

/* お気に入り上限の確認ポップアップ */
.fav-dialog-root {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 20px;
  box-sizing: border-box;
}

.fav-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 10, 0.72);
}

.fav-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 320px);
  padding: 18px 16px 14px;
  border-radius: 18px;
  background: rgba(16, 20, 28, 0.98);
  border: 1px solid rgba(193, 162, 109, 0.45);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  color: #fff;
}

.fav-dialog-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(212, 175, 55, 0.9);
}

.fav-dialog h2 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
}

.fav-dialog-body {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.78);
}

.fav-dialog-victim {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(193, 162, 109, 0.1);
  border: 1px solid rgba(193, 162, 109, 0.28);
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.85);
}

.fav-dialog-victim strong {
  color: var(--gold-soft);
  font-weight: 700;
}

.fav-dialog-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.fav-dialog-cancel,
.fav-dialog-ok {
  height: 42px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.fav-dialog-cancel {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.85);
}

.fav-dialog-ok {
  border: 0;
  color: #1a1204;
  background: linear-gradient(180deg, #e8d09a 0%, #c9a66a 48%, #a07f45 100%);
}

body.is-fav-dialog {
  overflow: hidden;
}

/* ========== AI cards ========== */
.ai-cards {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.ai-card {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 96px;
  border: 1px solid rgba(193, 162, 109, 0.28);
  background: #10141c;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.ai-card-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.72;
}

.ai-card-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(8, 10, 14, 0.88) 0%, rgba(8, 10, 14, 0.62) 46%, rgba(8, 10, 14, 0.28) 100%);
}

.ai-card-row {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(72px, auto);
  gap: 8px;
  align-items: center;
  padding: 12px 10px;
  min-height: 96px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

.ai-ico {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid rgba(193, 162, 109, 0.45);
  background: rgba(12, 14, 18, 0.55);
  display: grid;
  place-items: center;
  color: var(--gold-soft);
}

.ai-ico img {
  width: 18px;
  height: 18px;
  filter: invert(78%) sepia(28%) saturate(550%) hue-rotate(4deg) brightness(95%);
}

.ai-copy {
  min-width: 0;
  max-width: 100%;
}

.ai-kicker {
  margin: 0 0 2px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.ai-title {
  margin: 0;
  font-size: clamp(13px, 3.8vw, 16px);
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-desc {
  margin: 3px 0 0;
  font-size: 10px;
  line-height: 1.35;
  color: rgba(220, 220, 220, 0.72);
  overflow-wrap: anywhere;
}

.ai-side {
  display: grid;
  justify-items: center;
  gap: 6px;
  align-content: center;
  min-width: 0;
  max-width: 100%;
}

.ai-side--solo {
  align-content: end;
  padding-bottom: 2px;
}

.ai-gauge {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(10, 12, 16, 0.95) 57%, transparent 58%),
    conic-gradient(var(--gold-soft) calc(var(--p) * 1%), rgba(255, 255, 255, 0.08) 0);
  border: 1px solid rgba(193, 162, 109, 0.3);
}

.ai-gauge-num {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-soft);
  line-height: 1;
}

.ai-gauge-label {
  font-size: 7px;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 1px;
}

.ai-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 6px 8px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  background: linear-gradient(180deg, #e5c78f 0%, #c1a26d 45%, #9f7e4a 100%);
  box-shadow: 0 4px 12px rgba(160, 120, 50, 0.28);
}

/* ========== Heatmaps ========== */
.heat-card {
  background: var(--card);
  border: 1px solid rgba(193, 162, 109, 0.22);
  border-radius: var(--radius-lg);
  padding: 14px 12px 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}

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

.heat-note {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
}

.heat-title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.heat-legend {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--gold);
}

.heat-legend i {
  display: block;
  width: 52px;
  height: 6px;
  border-radius: 999px;
  /* 低(青緑) → 中(黄) → 高(赤) */
  background: linear-gradient(90deg, #1f8a8a 0%, #e6c84a 50%, #e24b4b 100%);
}

.heatmap-scroll,
.cond-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
  user-select: none;
}

.heatmap-scroll::-webkit-scrollbar,
.cond-table-wrap::-webkit-scrollbar {
  display: none;
}

.heatmap-scroll.is-dragging,
.cond-table-wrap.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}

.heatmap-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 4px 5px;
  font-size: 10px;
}

.heatmap-table th {
  color: var(--gold);
  font-weight: 600;
  text-align: center;
  padding: 0 2px 4px;
  white-space: nowrap;
}

.heatmap-table th.row-head,
.heatmap-table td .row-head {
  text-align: left;
  color: #fff;
  font-weight: 600;
  padding-right: 6px;
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 1;
}

.heatmap-table td {
  padding: 0;
  vertical-align: middle;
}

.hv {
  --v: 50;
  /* 低=青緑(180) → 中=黄 → 高=赤(0) */
  --heat-h: calc(180 - (var(--v) * 1.8));
  display: grid;
  grid-template-columns: 30px 42px;
  align-items: center;
  gap: 4px;
  padding: 4px 5px;
  border-radius: 6px;
  background: hsl(var(--heat-h) 58% 34%);
}

.hv b {
  font-weight: 600;
  color: #f7f1df;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.hv i {
  display: block;
  height: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
}

.hv i::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--v) * 1%);
  border-radius: inherit;
  background: hsl(var(--heat-h) 70% 55%);
}

.cond-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 6px 6px;
  font-size: 12px;
}

.cond-table th {
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  padding: 2px 4px;
}

.cond-table tbody th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.cond-table td {
  --v: 50;
  --heat-h: calc(180 - (var(--v) * 1.8));
  text-align: center;
  color: #f7f1df;
  font-weight: 600;
  padding: 8px 6px;
  border-radius: 6px;
  background: hsl(var(--heat-h) 58% 34%);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.heat-more {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  height: 38px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
}

/* ========== Catalog (existing JS views) ========== */
.main {
  display: none;
  padding: 12px var(--pad) 24px;
}

.main.is-catalog {
  display: block;
}

.is-catalog-view .mascot-ka0ba {
  display: none;
}

.muted { color: var(--muted); font-size: 0.9rem; }

.date-group { margin-bottom: 1.1rem; }
.date-label {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

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

.list-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.list-link.is-disabled { opacity: 0.45; pointer-events: none; }
.list-main { display: grid; gap: 0.15rem; min-width: 0; }
.list-title { font-weight: 700; }
.list-meta { font-size: 0.85rem; color: var(--muted); }
.chevron { color: var(--gold); }

.badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
}

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

.badge-no {
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

/* Race detail (JS-generated) */
.section { margin-bottom: 1.1rem; }
.section-title {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold);
}

.race-header {
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.race-header h2 {
  margin: 0 0 0.2rem;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 600;
}

.race-header .meta-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.marks { display: grid; gap: 0.45rem; }

.mark-row {
  display: grid;
  grid-template-columns: 2.6rem 2.5rem 1fr;
  gap: 0.55rem;
  align-items: center;
  padding: 0.7rem 0.8rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.mark-symbol {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
}

.mark-row.is-honmei .mark-symbol { color: var(--honmei); }
.mark-row.is-honmei {
  border-color: rgba(232, 180, 160, 0.35);
  background: rgba(232, 180, 160, 0.08);
}

.mark-num {
  font-family: var(--mono);
  font-weight: 700;
  text-align: center;
}

.mark-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-card {
  background: linear-gradient(145deg, rgba(193, 162, 109, 0.22), #16120c);
  border: 1px solid rgba(193, 162, 109, 0.4);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  color: #fff8e7;
}

.hero-label {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold-soft);
}

.hero-legs {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.9rem;
  font-weight: 800;
}

.hero-sub { margin: 0.3rem 0 0; font-size: 0.85rem; color: rgba(255, 248, 231, 0.75); }
.hero-comment {
  margin: 0.5rem 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(240, 215, 140, 0.25);
  font-size: 0.9rem;
}

.bet-tabs { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; }
.bet-tab {
  flex: 1;
  padding: 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.bet-tab.is-active {
  background: linear-gradient(180deg, #e5c78f, #9f7e4a);
  border-color: transparent;
  color: #1a1408;
}

.bet-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.bet-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
}
.bet-top { display: flex; justify-content: space-between; gap: 0.75rem; }
.bet-rank { font-size: 0.72rem; color: var(--muted); margin-right: 0.35rem; }
.bet-legs { font-family: var(--mono); font-weight: 700; }
.bet-score { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.bet-comment { margin: 0.25rem 0 0; font-size: 0.82rem; color: var(--muted); }

.confidence-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.confidence-dot { width: 0.65rem; height: 0.65rem; border-radius: 999px; }
.confidence-dot.band-high { background: var(--gold); }
.confidence-dot.band-medium { background: var(--warn); }
.confidence-dot.band-low { background: var(--danger); }
.confidence-dot.band-unknown { background: var(--muted); }
.confidence-line strong { color: var(--gold-soft); }

details.fold { margin-top: 0.4rem; }
details.fold > summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--gold);
  font-weight: 700;
  list-style: none;
}
details.fold > summary::-webkit-details-marker { display: none; }
.fold-body {
  margin-top: 0.45rem;
  padding: 0.7rem 0.85rem;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.narrative {
  margin: 0;
  padding: 0.7rem 0.9rem;
  background: var(--card);
  border-left: 3px solid var(--gold);
  border-radius: 0 12px 12px 0;
}

.reason-title { margin: 0.35rem 0 0.1rem; font-size: 0.83rem; font-weight: 700; }
.empty-state {
  padding: 1.4rem 1rem;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.disclaimer { margin: 0.35rem 0 0; font-size: 0.72rem; color: var(--muted); }
.footer { display: none; }

/* ========== Bottom nav ========== */
.bottom-nav {
  /* ビューポートではなく .app 内に固定（プレビュー幅でもズレない） */
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  z-index: 35;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(8, 10, 14, 0.94);
  border-top: 1px solid rgba(193, 162, 109, 0.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-sizing: border-box;
}

.bottom-nav a {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 4px 2px;
  color: #c1a26d;
  font-size: 10px;
  font-weight: 600;
  opacity: 0.62;
}

/* インライン SVG: currentColor でホームと同じ金の線画 */
.bottom-nav .nav-ico {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  color: inherit;
}

.bottom-nav a.is-active {
  color: var(--gold-soft);
  opacity: 1;
}

.bottom-nav a.is-active .nav-ico {
  color: var(--gold-soft);
}

/* 旧 img 運用の残骸があっても黒塗りにしない */
.bottom-nav a img {
  width: 22px;
  height: 22px;
  opacity: 1;
  filter: none;
}

/* Mascot overrides for mockup bubble */
.page-home .mascot-ka0ba .mascot-name { display: none; }

.page-home .mascot-ka0ba .mascot-bubble {
  border-radius: 14px;
  line-height: 1.4;
  font-size: 11px;
}

.page-home .mascot-ka0ba .mascot-bubble strong {
  color: #d4af37;
}

@media (max-width: 360px) {
  .dash-stats {
    gap: 8px;
  }
  .dash-time { font-size: 58px; }
  .dash-roi { font-size: 28px; }
  .ai-card-row {
    grid-template-columns: 30px minmax(0, 1fr) minmax(64px, auto);
    gap: 6px;
    padding: 10px 8px;
  }
  .ai-title { font-size: 13px; }
  .ai-desc { font-size: 9px; }
  .ai-gauge { width: 46px; height: 46px; }
  .ai-gauge-num { font-size: 12px; }
  .ai-pill { font-size: 9px; padding: 5px 7px; }
  .fav-card { flex-basis: 108px; }
}

/* 広いプレビューでもスマホ枠として中央に収める */
@media (min-width: 480px) {
  body {
    padding: 0;
    background:
      radial-gradient(80% 50% at 50% 0%, rgba(193, 162, 109, 0.06), transparent 55%),
      #05070c;
  }

  .app {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 18px 48px rgba(0, 0, 0, 0.45);
  }
}
