:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #faf9f7;
  --text: #1f1e1c;
  --text-sub: #5f5e5a;
  --text-muted: #8a8983;
  --border: #e6e4de;
  --border-strong: #cfccc4;
  --weekend: #f4f2ed;
  --today: #d4537e;
  --overall: #7f77dd;
  --top: #1d9e75;
  --mid: #d85a30;
  --low: #d4537e;
  --day-w: 12px;
  --label-w: 232px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191817;
    --surface: #201f1e;
    --surface-alt: #262524;
    --text: #f0eee9;
    --text-sub: #b3b1aa;
    --text-muted: #8a8983;
    --border: #35332f;
    --border-strong: #4a4741;
    --weekend: #232221;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 64px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

header { padding: 28px 0 18px; }
h1 { margin: 0 0 6px; font-size: 21px; font-weight: 600; letter-spacing: 0.01em; }
.meta { color: var(--text-sub); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.meta a { color: var(--text-sub); }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border-strong); font-size: 11.5px; color: var(--text-sub);
}
.badge.on { border-color: var(--today); color: var(--today); }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 18px 0 14px; }
.chip {
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-sub); border-radius: 999px; padding: 5px 13px;
  font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
input[type="search"] {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 6px 11px; font-size: 13px; font-family: inherit; min-width: 190px;
}

.chart { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.grid { min-width: max-content; }

.axis, .row { display: grid; grid-template-columns: var(--label-w) max-content; }
.axis { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border-strong); }
.axis .cell-label, .row .cell-label {
  position: sticky; left: 0; z-index: 7; background: var(--surface);
  border-right: 1px solid var(--border-strong); padding: 7px 12px;
}
.axis .cell-label { display: flex; align-items: flex-end; font-size: 11.5px; color: var(--text-muted); }
.track { position: relative; }
.axis .track { height: 52px; }
.row .track { height: 34px; }

.months { position: absolute; top: 6px; left: 0; right: 0; height: 16px; }
.month { position: absolute; font-size: 12px; font-weight: 600; color: var(--text-sub); padding-left: 5px; }
.tick { position: absolute; bottom: 4px; font-size: 10.5px; color: var(--text-muted); transform: translateX(-50%); white-space: nowrap; }
.tickline { position: absolute; bottom: 0; width: 1px; height: 6px; background: var(--border-strong); }

.weekend-layer, .gridline-layer { position: absolute; inset: 0; pointer-events: none; }
.weekend { position: absolute; top: 0; bottom: 0; background: var(--weekend); }
.vline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); }
.vline.month { background: var(--border-strong); }
.vline.today { background: var(--today); width: 2px; z-index: 1; }
.today-flag {
  position: absolute; top: 2px; font-size: 10.5px; color: var(--today);
  transform: translateX(-50%); white-space: nowrap; z-index: 2;
}

.section { grid-column: 1 / -1; display: grid; grid-template-columns: var(--label-w) max-content; background: var(--surface-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section .cell-label { position: sticky; left: 0; z-index: 7; background: var(--surface-alt); font-size: 11.5px; color: var(--text-sub); padding: 5px 12px; letter-spacing: 0.02em; }
.section .track { height: 26px; }

.row { border-bottom: 1px solid var(--border); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover .cell-label, .row:hover .track { background: var(--surface-alt); }
.row[aria-selected="true"] .cell-label { background: var(--surface-alt); box-shadow: inset 3px 0 0 var(--text); }
.row .cell-label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; line-height: 1.3; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lock { font-size: 10.5px; color: var(--today); border: 1px solid var(--today); border-radius: 4px; padding: 0 4px; flex: 0 0 auto; }

.bar { position: absolute; top: 9px; height: 15px; border-radius: 4px; z-index: 2; }
.bar.point { border-radius: 3px; }
.bar-text { position: absolute; top: 8px; font-size: 10.5px; color: var(--text-sub); white-space: nowrap; z-index: 2; }
.bar-inner { color: #fff; font-size: 10.5px; padding: 0 5px; line-height: 15px; overflow: hidden; white-space: nowrap; }

.detail { margin: 20px 0 0; border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; background: var(--surface); }
.detail h2 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.detail .kv { color: var(--text-sub); font-size: 12.5px; margin-bottom: 10px; }
.detail ul { margin: 0; padding-left: 18px; }
.detail li { margin-bottom: 3px; }
.detail .warn { margin-top: 10px; font-size: 12.5px; color: var(--today); }
.empty { color: var(--text-muted); font-size: 13px; }

footer { margin-top: 26px; color: var(--text-muted); font-size: 12px; }
footer ul { padding-left: 18px; margin: 6px 0 0; }

@media (max-width: 640px) {
  :root { --label-w: 140px; --day-w: 11px; }
  body { font-size: 13px; padding-bottom: 40px; }
  .wrap { padding: 0 12px; }
  header { padding: 18px 0 12px; }
  h1 { font-size: 17px; line-height: 1.35; }
  .meta { font-size: 11.5px; gap: 4px 10px; }
  .controls { gap: 6px; margin: 12px 0 10px; }
  .chip { padding: 5px 10px; font-size: 12px; }
  input[type="search"] { flex: 1 1 55%; min-width: 0; }
  .chart { border-radius: 10px; -webkit-overflow-scrolling: touch; }
  .axis .cell-label, .row .cell-label, .section .cell-label { padding: 5px 8px; }
  .axis .track { height: 46px; }
  .row .track { height: 40px; }
  .row .cell-label { font-size: 11.5px; align-items: center; }
  .row .name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .lock { font-size: 9.5px; padding: 0 3px; }
  .bar { top: 12px; height: 16px; }
  .bar-inner { line-height: 16px; }
  .bar-text { top: 11px; font-size: 10px; }
  .vline.today { width: 3px; }
  .today-flag { font-size: 10px; }
  .detail { padding: 13px 14px; border-radius: 10px; }
  .detail h2 { font-size: 15px; }
  footer { font-size: 11.5px; }
}

@media (max-width: 400px) {
  :root { --label-w: 124px; --day-w: 10px; }
}
