:root {
  --bg: #06090c;
  --panel: #11171b;
  --panel-2: #161f24;
  --line: #2d3940;
  --text: #f4f8fb;
  --muted: #9bacb9;
  --accent-sleep: #9f7cff;
  --accent-heart: #ff4d61;
  --accent-spo2: #ff5f5f;
  --accent-stress: #17d7cf;
  --shadow: 0 16px 40px rgba(0,0,0,.34);
  --font-main: "Zen Kaku Gothic New", sans-serif;
  --font-display: "Zen Old Mincho", "Noto Serif JP", serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 3%, rgba(42, 109, 160, 0.16) 0, transparent 24%),
    radial-gradient(circle at 93% 100%, rgba(101, 80, 162, 0.16) 0, transparent 26%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-main);
}

.container {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 12px 14px 36px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(6,9,12,.98), rgba(6,9,12,.92));
  padding: 8px 0 12px;
  backdrop-filter: blur(6px);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.back {
  border: 1px solid var(--line);
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: #0e1419;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

.site-menu {
  position: relative;
}

.site-menu summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: #0f151a;
  font-size: 1.22rem;
  line-height: 1;
}

.site-menu summary::-webkit-details-marker { display: none; }

.site-menu[open] summary {
  border-color: #4a5a64;
  background: #171f25;
}

.site-menu nav {
  position: absolute;
  right: 0;
  top: 40px;
  width: 180px;
  background: #151c22;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  z-index: 30;
}

.site-menu nav a {
  display: block;
  text-decoration: none;
  color: #e8eef3;
  padding: 10px 12px;
  border-top: 1px solid #253139;
  font-weight: 700;
}

.site-menu nav a:first-child { border-top: 0; }
.site-menu nav a:hover { background: #1f2930; }
.site-menu nav a.active { background: #2a3540; }

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4.8vw, 2.35rem);
  text-align: center;
  letter-spacing: .01em;
}

.date-row {
  margin-top: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

#date-select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
  font: inherit;
  color: var(--text);
  background: #0e1419;
}

.tabs {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
}

.metric-quick {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(16, 23, 28, 0.92);
  position: sticky;
  top: 146px;
  z-index: 18;
}

.metric-quick button,
.tab {
  border: 1px solid #344049;
  border-radius: 10px;
  background: #12191f;
  color: #dce4ea;
  font: inherit;
  font-weight: 800;
  padding: 9px 6px;
  cursor: pointer;
}

.tab {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  border-color: #4f616d;
  background: #36434d;
  color: #fff;
}

.hero {
  margin-top: 14px;
  padding: 12px 2px 4px;
}

.hero .big {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 10vw, 4.3rem);
  font-weight: 900;
  line-height: 1;
}

.hero .sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 1.08rem;
}

.card {
  margin-top: 14px;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.7rem;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid #2a363e;
}

.kpi {
  padding: 16px 8px 6px;
  min-height: 106px;
}

.kpi:nth-child(odd) { border-right: 1px solid #2a363e; }

.kpi .v {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6.5vw, 3.2rem);
  font-weight: 900;
}

.kpi .l {
  margin-top: 2px;
  color: #d2d9df;
  font-size: 1.45rem;
}

.metric-nav {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.metric-nav a {
  text-decoration: none;
  color: #d8dfe5;
  background: #10161c;
  border: 1px solid #2d3942;
  border-radius: 12px;
  text-align: center;
  padding: 10px 6px;
  font-weight: 800;
}

.metric-nav a.active {
  border-color: #5f7383;
  color: #fff;
  background: #26313b;
}

.canvas-wrap {
  border: 1px solid #2b3942;
  border-radius: 16px;
  padding: 8px 8px 4px;
  background: #0f151b;
}

canvas { width: 100%; min-height: 230px; }

.note {
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1.65;
}

@media (max-width: 520px) {
  .metric-quick {
    grid-template-columns: 1fr;
    top: 130px;
  }

  .container { padding: 10px 10px 24px; }
  .card { border-radius: 20px; padding: 12px; }
  .kpi .l { font-size: 1.2rem; }
}
