:root {
  --bg: #eef1f8;
  --bg2: #f6f8fc;
  --card: #ffffff;
  --card2: #ffffff;
  --ink: #1f2a44;
  --muted: #6b7794;
  --line: #e2e7f0;
  --accent: #2f6bff;
  --accent2: #7b5cff;
  --green: #0fa572;
  --yellow: #c08a00;
  --orange: #d9682a;
  --red: #e23b4e;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(31, 42, 68, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 500px at 50% -15%, #e6ecff 0%, rgba(238, 241, 248, 0) 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}

/* ---- ヘッダー ---- */
header.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
header.top h1 {
  font-size: 22px;
  margin: 0;
  letter-spacing: .02em;
}
header.top h1 .spark { color: var(--yellow); }
.subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }

.park-tabs {
  margin-left: auto;
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow);
}
.park-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
}
.park-tabs button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}

/* ---- コントロール ---- */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 700; }
.field input, .field select {
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.field input[type="range"] { padding: 0; accent-color: var(--accent); }
.time-val { color: var(--accent); font-weight: 700; }

/* ---- モード切替（予測 / ライブ） ---- */
.mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.mode-tabs {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow);
}
.mode-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: .15s;
}
.mode-tabs button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}
.mode-tabs button[data-mode="live"].active {
  background: linear-gradient(135deg, #e23b4e, #ff7a59);
}
.mode-status { font-size: 12px; color: var(--muted); }
.mode-status .live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); margin-right: 5px; box-shadow: 0 0 8px rgba(226,59,78,.7);
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }
.mode-status.err { color: var(--red); }
.card .status-txt { font-size: 13px; color: var(--muted); font-weight: 700; }
.card.dim { opacity: .6; }

/* ---- 学習バッジ ---- */
.model-badge {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg2);
  border: 1px dashed #cdd6e8;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 18px;
}
.model-badge b { color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 6px; box-shadow: 0 0 8px rgba(15,165,114,.6); }

/* ---- 一覧 ---- */
.section-title {
  font-size: 15px;
  margin: 6px 2px 12px;
  color: var(--muted);
  font-weight: 700;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 1px solid var(--line);
  transition: .15s transform, .15s border-color, .15s box-shadow;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 10px 28px rgba(47,107,255,.16); }
.card .name { font-weight: 800; font-size: 15px; line-height: 1.35; }
.card .meta { color: var(--muted); font-size: 12px; margin: 6px 0 12px; }
.card .wait {
  display: flex; align-items: baseline; gap: 6px;
}
.card .wait .num { font-size: 34px; font-weight: 900; line-height: 1; }
.card .wait .unit { font-size: 14px; color: var(--muted); }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  margin-top: 10px;
}
.lv-low    { background: rgba(15,165,114,.12);  color: var(--green); }
.lv-mid    { background: rgba(192,138,0,.14);   color: var(--yellow); }
.lv-high   { background: rgba(217,104,42,.14);  color: var(--orange); }
.lv-vhigh  { background: rgba(226,59,78,.12);   color: var(--red); }

/* ---- 詳細モーダル ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(31, 42, 68, .35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 50;
  backdrop-filter: blur(3px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(31, 42, 68, .25);
}
.modal h2 { margin: 0 0 4px; font-size: 19px; }
.modal .meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.modal-close {
  float: right; border: 1px solid var(--line); background: var(--bg2); color: var(--ink);
  width: 34px; height: 34px; border-radius: 50%; font-size: 18px; cursor: pointer;
}
.now-box {
  display: flex; gap: 20px; flex-wrap: wrap;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px;
}
.now-box .item .k { font-size: 12px; color: var(--muted); }
.now-box .item .v { font-size: 26px; font-weight: 900; }
canvas { width: 100%; height: 240px; display: block; }
.chart-wrap { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.legend { font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend .cur { color: var(--accent); font-weight: 800; }

footer.note { text-align: center; color: var(--muted); font-size: 11px; margin-top: 30px; line-height: 1.6; }
footer.note a { color: var(--accent); }
