/* Keiba Vision — design tokens
   無彩色の階調 + 芝のグリーン 1 色。すりガラスはサイドバー・バー・写真や3Dの上に重なる要素だけに使う。 */
:root {
  --bg: #f5f5f7;
  --bg-elev: #ffffff;
  --bg-sunken: #ececf0;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --ink: #1d1d1f;
  --ink-2: #424245;
  --ink-3: #6e6e73;
  --ink-4: #a1a1a6;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.14);
  --accent: #0a6b45;
  --accent-soft: rgba(10, 107, 69, 0.1);
  --accent-ink: #ffffff;
  --danger: #c4302b;
  --warn: #a35d00;
  --g1: #1c4fa0; --g2: #b3261e; --g3: #16794a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-2: 0 2px 6px rgba(0, 0, 0, 0.05), 0 18px 40px rgba(0, 0, 0, 0.08);
  --radius: 18px;
  --radius-s: 12px;
  --sans: "Inter", "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Segoe UI", sans-serif;
  --serif: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --num: "Inter", -apple-system, "SF Pro Text", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sidebar-w: 248px;
  /* 枠色 (JRA) */
  --w1: #ffffff; --w1t: #1d1d1f; --w2: #1d1d1f; --w2t: #fff; --w3: #d6312b; --w3t: #fff; --w4: #1f5fd1; --w4t: #fff;
  --w5: #f2c94c; --w5t: #1d1d1f; --w6: #2e9d57; --w6t: #fff; --w7: #f08a24; --w7t: #fff; --w8: #e66a9f; --w8t: #fff;
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-elev: #1c1c1e;
  --bg-sunken: #121214;
  --glass: rgba(28, 28, 30, 0.7);
  --glass-strong: rgba(36, 36, 38, 0.86);
  --ink: #f5f5f7;
  --ink-2: #d1d1d6;
  --ink-3: #98989d;
  --ink-4: #636366;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --accent: #3dbb84;
  --accent-soft: rgba(61, 187, 132, 0.14);
  --accent-ink: #04140d;
  --danger: #ff6b61;
  --warn: #f0a640;
  --g1: #6f9cf0; --g2: #f0776d; --g3: #4ec58a;
  --shadow-1: 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-2: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 24px 48px rgba(0, 0, 0, 0.5);
  --w1: #f5f5f7; --w2: #2c2c2e;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.6 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "palt";
  transition: background-color 0.3s, color 0.3s;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--ink-3); }
.fine { font-size: 12px; color: var(--ink-3); margin-top: 12px; line-height: 1.6; }
.note { font-size: 13px; color: var(--ink-3); margin-bottom: 14px; }
.eyebrow { font: 600 12px/1 var(--num); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ============ Splash: 発馬ゲート ============ */
.splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: #0b0b0c; color: #f5f5f7;
  overflow: hidden;
  perspective: 1400px;
}
.splash { place-items: start center; }
.splash-brand { position: relative; z-index: 2; text-align: center; padding: 16vh 16px 0; transition: opacity 0.5s, transform 0.8s var(--ease); }
.splash-kicker { font-size: 12px; letter-spacing: 0.2em; color: rgba(255, 255, 255, 0.55); opacity: 0; animation: rise 0.9s var(--ease) 0.2s forwards; }
.splash-title {
  font: 700 clamp(40px, 8vw, 84px)/1.1 var(--serif);
  letter-spacing: 0.02em; margin: 14px 0 28px;
  opacity: 0; animation: rise 1.1s var(--ease) 0.35s forwards;
}
.splash-progress { width: min(280px, 70vw); height: 1px; margin: 0 auto; background: rgba(255, 255, 255, 0.15); opacity: 0; animation: rise 0.8s var(--ease) 0.6s forwards; }
.splash-progress span { display: block; height: 100%; width: 0; background: #fff; transition: width 0.5s var(--ease); }
.splash-status { margin-top: 14px; font-size: 12px; color: rgba(255, 255, 255, 0.5); min-height: 1.6em; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.gate {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  display: flex; gap: 6px; height: 40vh; width: min(1100px, 96vw);
  opacity: 0; animation: gateIn 1.2s var(--ease) 0.1s forwards;
}
@keyframes gateIn { from { opacity: 0; transform: translate(-50%, 40px); } to { opacity: 1; transform: translate(-50%, 0); } }
.stall { position: relative; flex: 1; display: flex; border-top: 3px solid #2a2a2c; perspective: 600px; }
.stall::before {
  content: attr(data-n); position: absolute; top: -34px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 22px; border-radius: 4px; display: grid; place-items: center;
  font: 700 12px var(--num); background: var(--c); color: var(--t); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.door {
  flex: 1; background: linear-gradient(180deg, #2b2b2e, #1a1a1c);
  border: 1px solid #333336;
  background-image: repeating-linear-gradient(180deg, transparent 0 22px, rgba(255, 255, 255, 0.05) 22px 23px), linear-gradient(180deg, #2b2b2e, #1a1a1c);
  transition: transform 0.9s cubic-bezier(0.5, 0, 0.1, 1);
}
.door.l { transform-origin: left center; }
.door.r { transform-origin: right center; }
.splash.open .door.l { transform: rotateY(-105deg); }
.splash.open .door.r { transform: rotateY(105deg); }
.splash.open .splash-brand { opacity: 0; transform: translateY(-30px) scale(0.98); }
.splash.leave { opacity: 0; transition: opacity 0.6s ease 0.55s; pointer-events: none; }
.splash-skip {
  position: absolute; right: 20px; bottom: 20px; z-index: 3;
  background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 999px; padding: 6px 14px; font-size: 12px; cursor: pointer;
}
.shell { opacity: 0; }
body.ready .shell { opacity: 1; transition: opacity 0.6s ease 0.2s; }
body.ready .view.on > * { animation: up 0.8s var(--ease) both; }
body.ready .view.on > :nth-child(2) { animation-delay: 0.05s; }
body.ready .view.on > :nth-child(3) { animation-delay: 0.1s; }
body.ready .view.on > :nth-child(n+4) { animation-delay: 0.15s; }
@keyframes up { from { opacity: 0; transform: translateY(16px); } }

/* ============ Layout ============ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 12px 14px;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-right: 1px solid var(--line);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 14px; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 20px; height: 20px; stroke: var(--accent-ink); stroke-width: 3; }
.brand-name { font: 700 17px var(--serif); letter-spacing: 0.02em; }
.nav { position: relative; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav a {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 9px;
  color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500;
  transition: color 0.2s;
}
.nav a svg { color: var(--ink-3); transition: color 0.2s; }
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); font-weight: 600; }
.nav a.on svg { color: var(--accent); }
.nav-pill {
  position: absolute; left: 0; top: 0; width: 100%; border-radius: 9px;
  background: var(--bg-elev); box-shadow: var(--shadow-1), 0 0 0 1px var(--line);
  transition: transform 0.45s var(--ease), height 0.3s var(--ease);
}
.nav-label { font-size: 11px; font-weight: 600; color: var(--ink-4); letter-spacing: 0.08em; padding: 16px 10px 4px; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 6px 0; border-top: 1px solid var(--line); }
.account { min-width: 0; flex: 1; }
.account button { background: none; border: 0; padding: 4px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); max-width: 100%; }
.account img { width: 24px; height: 24px; border-radius: 50%; }
.theme-switch {
  position: relative; width: 52px; height: 28px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--bg-sunken); box-shadow: inset 0 0 0 1px var(--line); flex-shrink: 0;
}
.theme-switch svg { position: absolute; top: 5px; width: 18px; height: 18px; transition: transform 0.4s var(--ease), opacity 0.3s; }
.theme-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-elev); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.4s var(--ease);
}
.ts-sun { left: 5px; z-index: 1; color: #b7791f; }
.ts-moon { right: 5px; z-index: 1; color: var(--ink-3); }
[data-theme="dark"] .theme-switch::after { transform: translateX(24px); }
[data-theme="dark"] .ts-sun { color: var(--ink-3); }
[data-theme="dark"] .ts-moon { color: #f5f5f7; }

.main { min-width: 0; padding: 32px clamp(16px, 4vw, 48px) 80px; }
.view { display: none; max-width: 1240px; margin: 0 auto; }
.view.on { display: block; }
.view-flush { max-width: none; margin: -32px calc(-1 * clamp(16px, 4vw, 48px)) -80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.title { font: 700 clamp(28px, 3.4vw, 40px)/1.15 var(--serif); letter-spacing: 0.01em; }
.display { font: 700 clamp(34px, 5vw, 60px)/1.1 var(--serif); letter-spacing: 0.01em; }
.block { margin-top: 40px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 14px; }
.block-head h2 { font: 700 22px var(--serif); }
.link { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; color: var(--accent); text-decoration: none; font-weight: 500; }
.link svg { width: 16px; height: 16px; }

/* ============ Components ============ */
.card {
  background: var(--bg-elev); border-radius: var(--radius); padding: 22px 24px;
  box-shadow: var(--shadow-1); border: 1px solid var(--line); margin-bottom: 20px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h3, .card h3 { font-size: 16px; font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .actions { margin-top: 20px; }
.glass {
  background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--line); box-shadow: var(--shadow-2);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px; border: 0; cursor: pointer;
  font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: transform 0.15s, background 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--bg-sunken); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { background: var(--line); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.small svg { width: 16px; height: 16px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn-row.end { justify-content: flex-end; }
.actions { display: flex; justify-content: center; margin: 24px 0; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: var(--glass-strong); backdrop-filter: blur(12px); box-shadow: 0 0 0 1px var(--line); }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg-sunken); box-shadow: inset 0 0 0 1px var(--line); }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--ink-2); font-weight: 500; transition: background 0.2s, color 0.2s, box-shadow 0.2s; }
.seg.small button { padding: 4px 10px; font-size: 13px; }
.seg button.on { background: var(--bg-elev); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px var(--line); font-weight: 600; }

input[type="search"], input[type="number"], input[type="text"], select, textarea {
  height: 40px; border-radius: 10px; border: 0; padding: 0 12px;
  background: var(--bg-sunken); box-shadow: inset 0 0 0 1px var(--line); outline: none; transition: box-shadow 0.2s;
}
textarea { height: auto; padding: 10px 12px; width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-soft); }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--ink-3); }
.field > span em { font-style: normal; float: right; font-family: var(--num); }
.field input, .field select { color: var(--ink); width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.search { position: relative; flex: 1 1 260px; display: flex; }
.search svg { position: absolute; left: 12px; top: 11px; color: var(--ink-3); }
.search input { width: 100%; padding-left: 38px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font: 700 11px var(--num); letter-spacing: 0.02em; white-space: nowrap; }
.badge.g1 { background: var(--g1); color: #fff; }
.badge.g2 { background: var(--g2); color: #fff; }
.badge.g3 { background: var(--g3); color: #fff; }
.badge.other { background: var(--bg-sunken); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.waku { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; font: 700 12px var(--num); background: var(--c); color: var(--t); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); flex-shrink: 0; }
.credit { font-size: 11px; color: var(--ink-3); }
.credit a { color: inherit; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--bg-elev); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover { background: var(--bg-sunken); }
.table .sub { display: block; font-size: 12px; color: var(--ink-3); }
.table .mark { font-size: 18px; font-weight: 700; text-align: center; }
.bar { height: 4px; border-radius: 2px; background: var(--bg-sunken); overflow: hidden; min-width: 70px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.star { border: 0; background: none; cursor: pointer; color: var(--ink-4); padding: 2px; }
.star.on { color: #c99a2e; }
.star.on svg { fill: currentColor; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; z-index: 90;
  background: var(--glass-strong); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-2); font-size: 14px; pointer-events: none;
  transition: opacity 0.3s, transform 0.4s var(--ease);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ============ Home ============ */
.hero { position: relative; height: clamp(320px, 46vh, 460px); border-radius: 24px; overflow: hidden; background: #1b2a20; color: #fff; }
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.04); opacity: 0; transition: opacity 1.2s ease, transform 8s ease-out; }
.hero-img.loaded { opacity: 1; transform: scale(1); }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 30%, rgba(0, 0, 0, 0.65)); }
.hero-body { position: absolute; left: clamp(20px, 4vw, 44px); right: 20px; bottom: clamp(22px, 4vw, 40px); }
.hero-body .eyebrow { color: rgba(255, 255, 255, 0.75); }
.hero-lead { margin-top: 10px; color: rgba(255, 255, 255, 0.85); font-size: 15px; }
.hero-credit { position: absolute; right: 14px; bottom: 10px; color: rgba(255, 255, 255, 0.6); max-width: 50%; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 20px; border-radius: var(--radius); overflow: hidden; background: var(--line); border: 1px solid var(--line); }
.stat { background: var(--bg-elev); padding: 18px 20px; }
.stat b { display: block; font: 600 28px/1.1 var(--num); letter-spacing: -0.02em; }
.stat span { font-size: 13px; color: var(--ink-3); }
.weather-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.wx { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; text-decoration: none; transition: transform 0.2s var(--ease), box-shadow 0.2s; }
.wx:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.wx strong { font-size: 14px; }
.wx svg { grid-row: span 2; align-self: center; width: 26px; height: 26px; color: var(--ink-2); }
.wx .t { font: 600 18px var(--num); }
.wx .c { grid-column: span 2; font-size: 12px; color: var(--ink-3); }
.wx .c b { font-weight: 600; }
.cond-good { color: var(--accent); } .cond-wet { color: var(--warn); } .cond-bad { color: var(--danger); }
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; }
.rail > * { scroll-snap-align: start; }

/* ============ Horse cards ============ */
.horse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.hcard { position: relative; display: flex; flex-direction: column; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; padding: 0; transition: transform 0.25s var(--ease), box-shadow 0.25s; }
.hcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.hcard .ph { aspect-ratio: 4 / 3; background: var(--bg-sunken); overflow: hidden; position: relative; }
.hcard .ph img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.5s, transform 0.6s var(--ease); }
.hcard .ph img.loaded { opacity: 1; }
.hcard:hover .ph img { transform: scale(1.04); }
.hcard .ph .sil { position: absolute; inset: 18% 14%; opacity: 0.85; }
.hcard .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.hcard .name { font-weight: 700; font-size: 16px; line-height: 1.3; }
.hcard .meta { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hcard .rating { position: absolute; top: 10px; right: 10px; padding: 3px 8px; border-radius: 999px; font: 600 12px var(--num); color: var(--ink); background: var(--glass-strong); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.hcard .wins { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.skeleton { background: linear-gradient(90deg, var(--bg-sunken), var(--line), var(--bg-sunken)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius); min-height: 260px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { padding: 60px 20px; text-align: center; color: var(--ink-3); grid-column: 1 / -1; }

/* Sheet (詳細) */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; transition: opacity 0.3s; }
.sheet-panel {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(560px, calc(100vw - 24px));
  background: var(--bg-elev); border-radius: 22px; overflow-y: auto; box-shadow: var(--shadow-2);
  transform: translateX(105%); transition: transform 0.5s var(--ease);
}
.sheet.on .sheet-backdrop { opacity: 1; }
.sheet.on .sheet-panel { transform: none; }
.sheet-close { position: sticky; top: 12px; float: right; margin: 12px 12px 0 0; z-index: 2; }
.detail-photo { position: relative; aspect-ratio: 3 / 2; background: var(--bg-sunken); margin-top: -48px; }
.detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.detail-photo .sil { position: absolute; inset: 15% 20%; }
.detail-body { padding: 22px 26px 30px; }
.detail-body h2 { font: 700 30px/1.2 var(--serif); }
.detail-body .en { color: var(--ink-3); font-size: 14px; margin-top: 2px; }
.facts { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; font-size: 14px; margin: 18px 0; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; }
.wins-list { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.wins-list li { display: flex; gap: 10px; align-items: center; }
.summary { font-size: 14px; line-height: 1.85; color: var(--ink-2); }
.meter { display: flex; align-items: center; gap: 12px; margin: 16px 0 4px; }
.meter .bar { flex: 1; height: 6px; }
.meter b { font: 600 22px var(--num); }
.photo-credit { padding: 8px 26px 0; }

/* ============ Races ============ */
.race-hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; }
.race-hero h2 { font: 700 30px/1.2 var(--serif); margin: 6px 0 4px; }
.race-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--ink-3); }
.race-facts { display: flex; gap: 20px; margin-top: 12px; font-size: 13px; color: var(--ink-3); }
.race-facts b { display: block; color: var(--ink); font: 600 18px var(--num); }
.wx-box { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 14px; background: var(--bg-sunken); }
.wx-box svg { width: 34px; height: 34px; color: var(--ink-2); }
.wx-box b { font: 600 24px var(--num); display: block; }
.mc { display: flex; flex-direction: column; gap: 7px; }
.mc-row { display: grid; grid-template-columns: 24px minmax(80px, 140px) 1fr 112px; gap: 10px; align-items: center; font-size: 13px; }
.mc-row .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.mc-track { position: relative; height: 8px; border-radius: 4px; background: var(--bg-sunken); overflow: hidden; }
.mc-track i { position: absolute; inset: 0 auto 0 0; border-radius: 4px; transition: width 0.7s var(--ease); }
.mc-track .p { background: var(--accent); opacity: 0.22; }
.mc-track .w { background: var(--accent); }
.mc-row .v { text-align: right; font-family: var(--num); font-variant-numeric: tabular-nums; }
.mc-row .v small { color: var(--ink-3); margin-left: 4px; }
.bets { display: flex; flex-direction: column; }
.bet { display: grid; grid-template-columns: 64px 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.bet:last-child { border-bottom: 0; }
.bet .type { font-size: 13px; font-weight: 600; color: var(--accent); }
.bet .combo { font: 600 16px var(--num); }
.bet .alloc { font: 600 14px var(--num); }
.bet p { grid-column: 2 / -1; font-size: 13px; color: var(--ink-3); }

/* ============ Sim ============ */
.sim { display: grid; grid-template-columns: 1fr 340px; height: 100vh; }
.sim-stage { position: relative; overflow: hidden; background: linear-gradient(#a9c7e3, #e8eef3); }
[data-theme="dark"] .sim-stage { background: linear-gradient(#0d1520, #1b2633); }
#sim-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sim-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 14px; pointer-events: none; transition: opacity 0.4s; }
.sim-loading.done { opacity: 0; }
.sim-hud { position: absolute; left: 16px; top: 16px; border-radius: 16px; padding: 12px 14px; width: 240px; max-height: calc(100% - 100px); overflow: hidden; display: flex; flex-direction: column; }
.hud-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.hud-remain { font: 600 20px var(--num); color: var(--ink); }
.hud-clock { font-family: var(--num); }
.hud-order { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.hud-order li { display: grid; grid-template-columns: 18px 24px 1fr; gap: 8px; align-items: center; font-size: 13px; height: 26px; transition: transform 0.35s var(--ease); }
.hud-order li .pos { font: 600 12px var(--num); color: var(--ink-3); text-align: right; }
.hud-order li .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sim-cams { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 999px; }
.sim-cams button { height: 34px; min-width: 38px; border: 0; background: none; border-radius: 999px; cursor: pointer; display: grid; place-items: center; font: 600 13px var(--num); color: var(--ink-2); }
.sim-cams button.on { background: var(--bg-elev); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }
.sim-cams .sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; }
.sim-result { position: absolute; right: 16px; top: 16px; width: min(320px, calc(100% - 32px)); border-radius: 18px; padding: 16px 18px; max-height: calc(100% - 100px); overflow-y: auto; }
.sim-result h3 { font: 700 18px var(--serif); margin-bottom: 8px; }
.result-list { list-style: none; padding: 0; margin: 0 0 12px; font-size: 13px; }
.result-list li { display: grid; grid-template-columns: 22px 24px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); }
.result-list li:first-child .pos { color: #b8892a; }
.result-list .pos { font: 700 13px var(--num); }
.result-list .gap { font: 12px var(--num); color: var(--ink-3); }
.sim-panel { border-left: 1px solid var(--line); background: var(--bg-elev); padding: 22px 20px; overflow-y: auto; }
.panel-title { font: 700 20px var(--serif); margin-bottom: 16px; }
.search-add { position: relative; display: flex; }
.search-add svg { position: absolute; left: 11px; top: 11px; color: var(--ink-3); }
.search-add input { width: 100%; padding-left: 36px; color: var(--ink); }
.suggest { position: absolute; top: 44px; left: 0; right: 0; z-index: 5; list-style: none; margin: 0; padding: 6px; background: var(--glass-strong); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: 12px; box-shadow: var(--shadow-2); max-height: 280px; overflow-y: auto; }
.suggest li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--ink); }
.suggest li:hover, .suggest li.on { background: var(--accent-soft); }
.suggest small { color: var(--ink-3); }
.field-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow-y: auto; }
.field-list li { display: grid; grid-template-columns: 24px 1fr auto auto; gap: 8px; align-items: center; font-size: 13px; color: var(--ink); padding: 4px 4px 4px 0; }
.field-list .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field-list select { height: 28px; font-size: 12px; padding: 0 22px 0 8px; background-position: right 4px center; background-size: 14px; }
.field-list button { border: 0; background: none; cursor: pointer; color: var(--ink-3); padding: 2px; }
.field-list .r { font: 12px var(--num); color: var(--ink-3); }

/* ============ Live ============ */
.player { margin-bottom: 12px; }
.player-frame { aspect-ratio: 16 / 9; background: #000; display: grid; place-items: center; }
.player-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.player-empty { color: rgba(255, 255, 255, 0.5); font-size: 14px; }
.player-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
.player-meta { flex: 1; min-width: 180px; display: flex; flex-direction: column; }
.player-meta .muted { font-size: 12px; }
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 20px; }
.live-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--bg-elev); border: 1px solid var(--line); cursor: pointer; text-align: left; transition: box-shadow 0.2s, transform 0.2s var(--ease); }
.live-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.live-item.on { box-shadow: inset 0 0 0 2px var(--accent); }
.live-item .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-sunken); color: var(--ink-2); }
.live-item strong { display: block; font-size: 14px; }
.live-item small { color: var(--ink-3); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

/* ============ Courses ============ */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.ccard { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform 0.25s var(--ease), box-shadow 0.25s; text-align: left; padding: 0; }
.ccard:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.ccard .ph { position: relative; aspect-ratio: 16 / 9; background: var(--bg-sunken); overflow: hidden; }
.ccard .ph img { width: 100%; height: 100%; object-fit: cover; }
.ccard .tag { position: absolute; left: 10px; top: 10px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--glass-strong); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.ccard .wxs { position: absolute; right: 10px; top: 10px; display: flex; gap: 4px; align-items: center; padding: 3px 9px; border-radius: 999px; font: 600 12px var(--num); background: var(--glass-strong); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.ccard .wxs svg { width: 14px; height: 14px; }
.ccard .body { padding: 14px 16px 16px; }
.ccard h3 { font: 700 19px var(--serif); }
.ccard .specs { display: flex; gap: 14px; font-size: 13px; color: var(--ink-3); margin-top: 4px; }
.ccard .specs b { color: var(--ink); font-family: var(--num); font-weight: 600; }
.course-detail .detail-photo { aspect-ratio: 16 / 9; }
.course-svg { width: 100%; height: auto; margin: 10px 0; stroke: none; }
.course-svg .outer { fill: #b99a6b; opacity: 0.45; }
.course-svg .turf { fill: #4c8a46; }
.course-svg .dirt { fill: #a7845a; }
.course-svg .inner { fill: var(--bg-sunken); stroke: var(--line-strong); }
.course-svg .straight { stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.course-svg .goal { stroke: var(--danger); stroke-width: 3; }
.course-svg text { font: 600 10px var(--sans); fill: var(--ink-2); }
.course-svg .elev { fill: none; stroke: var(--accent); stroke-width: 2; }
.course-svg .elev-fill { fill: var(--accent-soft); }

/* ============ Pedigree / knowledge / tools ============ */
.calc { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; align-items: center; }
.calc-in { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.calc-in input { width: 72px; text-align: center; margin: 0 4px; }
.calc-in .x { color: var(--ink-3); }
.calc-out { padding: 24px; border-radius: 16px; background: var(--bg-sunken); text-align: center; }
.calc-out .big { font: 600 52px/1 var(--num); letter-spacing: -0.03em; }
.calc-out .big small { font-size: 22px; color: var(--ink-3); margin-left: 2px; }
.calc-out .lbl { font-size: 13px; color: var(--ink-3); margin-top: 8px; }
.calc-out .tag { display: inline-block; margin-top: 12px; padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-elev); }
.calc-out .tag.r1 { color: var(--accent); } .calc-out .tag.r2 { color: var(--danger); }
.tree { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 24px; }
.tree-root { font: 700 16px var(--serif); padding-bottom: 6px; border-bottom: 2px solid var(--ink); display: inline-block; }
.tree-root small { display: block; font: 500 12px var(--sans); color: var(--ink-3); }
.tree ul { list-style: none; margin: 10px 0 0 6px; padding-left: 16px; border-left: 1px solid var(--line-strong); }
.tree li { position: relative; padding: 5px 0; font-size: 14px; font-weight: 600; }
.tree li::before { content: ""; position: absolute; left: -16px; top: 16px; width: 12px; border-top: 1px solid var(--line-strong); }
.tree li span { display: block; font-weight: 400; font-size: 12px; color: var(--ink-3); }
.lcard h3 { font: 700 18px var(--serif); margin-bottom: 4px; }
.lcard dl { display: grid; grid-template-columns: 84px 1fr; gap: 4px 12px; font-size: 13px; margin: 12px 0; }
.lcard dt { color: var(--ink-3); } .lcard dd { margin: 0; }
.lcard p { font-size: 14px; color: var(--ink-2); line-height: 1.75; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { padding: 3px 10px; border-radius: 999px; font-size: 12px; background: var(--bg-sunken); box-shadow: inset 0 0 0 1px var(--line); }
.size-chart { display: flex; align-items: flex-end; gap: 12px; overflow-x: auto; padding: 8px 0 4px; }
.size-item { flex: 1 0 74px; display: flex; flex-direction: column; align-items: center; margin: 0; }
.size-item .art { height: 56px; display: flex; align-items: flex-end; margin-bottom: 4px; }
.size-item .art svg { height: 100%; width: auto; }
.size-bar { width: 100%; border-radius: 8px 8px 2px 2px; background: var(--accent); opacity: 0.85; display: flex; justify-content: center; padding-top: 4px; font: 600 11px var(--num); color: var(--accent-ink); transform-origin: bottom; animation: grow 0.9s var(--ease) both; animation-delay: var(--d); }
.size-item.human .size-bar { background: var(--ink-4); }
.size-item figcaption { font-size: 12px; color: var(--ink-2); margin-top: 6px; text-align: center; border-top: 1px solid var(--line-strong); width: 100%; padding-top: 6px; }
@keyframes grow { from { transform: scaleY(0); } }
.breed-grid, .coat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 30px; }
.coat-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.kcard { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.kcard .fig { background: var(--bg-sunken); border-radius: 12px; padding: 14px 24px; margin-bottom: 12px; }
.kcard h3 { font: 700 17px var(--serif); }
.kcard h3 small { font: 400 12px var(--sans); color: var(--ink-3); margin-left: 6px; }
.kcard p { font-size: 13px; color: var(--ink-2); line-height: 1.7; margin-top: 6px; }
.kcard .spec { font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.sil-shadow { fill: rgba(0, 0, 0, 0.12); }

.list .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list .row:first-child { padding-top: 0; }
.list .row:last-child { border-bottom: 0; padding-bottom: 0; }
.list .muted { font-size: 13px; margin-top: 2px; }
.prose ul { padding-left: 18px; font-size: 14px; line-height: 1.9; color: var(--ink-2); }
.prose a { color: var(--accent); }

.dialog { border: 0; border-radius: 20px; padding: 26px; width: min(420px, calc(100vw - 32px)); background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-2); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(4px); }
.dialog form { display: flex; flex-direction: column; gap: 10px; }
.dialog h3 { font: 700 20px var(--serif); }
.dialog .muted { font-size: 13px; margin-bottom: 8px; }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .sim { grid-template-columns: 1fr; height: auto; }
  .sim-stage { height: 62vh; min-height: 380px; }
  .sim-panel { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .nav { min-width: 0; }
  .sidebar { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); gap: 6px; }
  .brand { padding: 0 6px 0 0; }
  .brand-name { display: none; }
  .nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 7px 10px; }
  .nav-label { display: none; }
  .sidebar-foot { border-top: 0; padding: 0; }
  .account { display: none; }
  .main { padding: 20px 16px 60px; }
  .view-flush { margin: -20px -16px -60px; }
  .grid-2, .calc, .race-hero { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .hero { border-radius: 18px; }
  .mc-row { grid-template-columns: 22px 80px 1fr 92px; font-size: 12px; }
  .sim-hud { width: 190px; padding: 10px; }
  .hud-order li { font-size: 12px; height: 22px; }
  .card { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}
