:root {
  color-scheme: light;
  --ink: #17211b;
  --muted: #62716a;
  --line: #dce4dc;
  --panel: #ffffff;
  --paper: #f5f7f2;
  --green: #1f7a4d;
  --green-dark: #135536;
  --gold: #b78121;
  --red: #b6473f;
  --blue: #2f5d86;
  --shadow: 0 18px 42px rgba(23, 33, 27, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: var(--green-dark);
}

.hero {
  min-height: 420px;
  position: relative;
  overflow: hidden;
  background-image: url("./hero-racing.png");
  background-size: cover;
  background-position: center bottom;
  color: #fff;
}

.hero__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(11, 24, 16, 0.88), rgba(11, 24, 16, 0.55) 42%, rgba(11, 24, 16, 0.08));
}

.topbar,
.hero__content {
  position: relative;
  z-index: 1;
  max-width: 1220px;
  margin: 0 auto;
  padding: 22px 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
}

.topbar__meta {
  display: flex;
  gap: 14px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
}

.hero__content {
  padding-top: 76px;
  max-width: 1220px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

.hero .eyebrow {
  color: #f0c266;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 740px;
  font-size: clamp(38px, 5vw, 68px);
  line-height: 1.02;
  margin-bottom: 18px;
}

.hero__content p:not(.eyebrow) {
  max-width: 660px;
  font-size: 18px;
  line-height: 1.75;
  color: rgba(255, 255, 255, 0.9);
}

main {
  max-width: 1280px;
  margin: -42px auto 0;
  padding: 0 24px 46px;
  position: relative;
  z-index: 2;
}

.control-band,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-band {
  padding: 18px;
}

.race-finder {
  margin-top: 18px;
}

.feed-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 11px;
  background: #eef3ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.feed-status.is-live {
  background: #dff1e7;
  color: var(--green-dark);
}

.feed-status.is-demo {
  background: #fff3d3;
  color: #7a5415;
}

.feed-status.is-loading {
  background: #e5edf5;
  color: var(--blue);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
}

.finder-grid {
  display: grid;
  grid-template-columns: 160px 160px minmax(220px, 1fr) 150px;
  gap: 12px;
  align-items: end;
}

.race-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.race-card {
  display: grid;
  gap: 5px;
  min-height: 108px;
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfcfa;
  color: var(--ink);
  text-align: left;
  padding: 14px;
  border-radius: 8px;
}

.race-card:hover,
.race-card.is-selected {
  border-color: var(--green);
  background: #eef7f0;
  color: var(--ink);
}

.race-card strong {
  font-size: 16px;
}

.race-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.race-card__meta {
  color: var(--green-dark);
  font-weight: 800;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  color: var(--ink);
  background: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  padding: 18px;
}

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

.panel__head h2 {
  margin: 0;
  font-size: 21px;
}

.icon-button {
  width: 38px;
  padding: 0;
  border-radius: 50%;
}

.weights-list {
  display: grid;
  gap: 14px;
}

.weight-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
  align-items: center;
}

.weight-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.weight-row input[type="range"] {
  grid-column: 1 / -1;
  padding: 0;
  min-height: 18px;
}

.note,
.source-note {
  margin-top: 16px;
  color: var(--muted);
  background: #f0f4ee;
  border-left: 4px solid var(--green);
  padding: 12px;
  border-radius: 6px;
  line-height: 1.65;
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.actions button:nth-child(2),
.actions button:nth-child(3) {
  background: #fff;
  color: var(--green-dark);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  border-collapse: collapse;
  min-width: 1120px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  background: #edf3ed;
  color: #33443a;
  position: sticky;
  top: 0;
  z-index: 1;
}

td input,
td select {
  min-height: 34px;
  padding: 5px 7px;
}

.short {
  width: 64px;
}

.horse-name {
  min-width: 140px;
}

.mark {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #e7eee8;
  color: var(--green-dark);
  font-weight: 800;
}

.ev-positive {
  color: var(--green-dark);
  font-weight: 800;
}

.ev-negative {
  color: var(--red);
  font-weight: 800;
}

.recommendation {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.rec-buy {
  background: #dff1e7;
  color: var(--green-dark);
}

.rec-watch {
  background: #fff3d3;
  color: #7a5415;
}

.rec-pass {
  background: #f6e3e1;
  color: #8b332c;
}

.insights {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 18px;
  margin-top: 18px;
}

.bet-cards {
  display: grid;
  gap: 12px;
}

.bet-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 8px;
}

.bet-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bet-card h3 {
  margin: 0;
  font-size: 18px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.metric {
  background: #f4f7f3;
  border-radius: 6px;
  padding: 8px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 2px;
}

.metric strong {
  font-size: 16px;
}

.driver {
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

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

.factor-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfa;
}

.factor-grid h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.factor-grid p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 13px;
}

footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 36px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .control-grid,
  .finder-grid,
  .workspace,
  .insights {
    grid-template-columns: 1fr;
  }

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

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

  main {
    margin-top: -28px;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar__meta {
    display: none;
  }

  .hero {
    min-height: 500px;
    background-position: 45% bottom;
  }

  .hero__content {
    padding-top: 64px;
  }

  h1 {
    font-size: 38px;
  }

  .control-grid,
  .finder-grid,
  .weights-list,
  .factor-grid,
  .metrics,
  .race-cards {
    grid-template-columns: 1fr;
  }

  .panel__head {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
    justify-content: stretch;
  }

  .actions button {
    flex: 1 1 120px;
  }
}
