:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --line: #262c36;
  --text: #e6edf3;
  --muted: #8b949e;
  --ok: #3fb950;
  --degraded: #d29922;
  --outage: #f85149;
  --maintenance: #58a6ff;
  --unknown: #6e7681;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans JP", sans-serif;
  font-size: 13px;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); }
button, a { font: inherit; }
button { cursor: pointer; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spacer { flex: 1; }

/* 状態色（.dot を持つ要素に status-<status> を付ける） */
.dot { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--unknown); }
.status-operational > .dot, .status-ok > .dot { background: var(--ok); }
.status-degraded > .dot { background: var(--degraded); }
.status-outage > .dot, .status-ng > .dot { background: var(--outage); }
.status-maintenance > .dot { background: var(--maintenance); }
.status-unknown > .dot { background: var(--unknown); }

.topbar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 20px; height: 44px; padding: 0 max(20px, calc((100% - 1180px) / 2 + 20px)); border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { color: var(--text); font-weight: 600; text-decoration: none; }
.updated-at { color: var(--muted); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.refresh-button { padding: 3px 10px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); background: transparent; font-size: 12px; }
.refresh-button:hover { color: var(--text); border-color: var(--muted); }
.refresh-icon { display: inline-block; margin-right: 4px; transition: transform .4s ease; }
.refresh-button.is-refreshing .refresh-icon { transform: rotate(180deg); }

.content { max-width: 1180px; margin: 0 auto; padding: 16px 20px 32px; }
.fetch-error { margin: 0 0 12px; padding: 8px 12px; border-left: 2px solid var(--outage); color: var(--outage); background: var(--surface); }

/* 全サービスの概要（サービスリストと同じ幅） */
.overall { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 10px 14px; border: 1px solid var(--line); border-left-width: 3px; border-radius: 4px; background: var(--surface); }
.overall.status-operational { border-left-color: var(--ok); }
.overall.status-degraded { border-left-color: var(--degraded); }
.overall.status-outage { border-left-color: var(--outage); }
.overall.status-maintenance { border-left-color: var(--maintenance); }
.overall.status-unknown { border-left-color: var(--unknown); }
.overall-label { font-weight: 600; }
.overall-count { color: var(--muted); font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* サービス：名前 → タイムライン →（展開時）コンポーネント の縦3段 */
.service-list { border: 1px solid var(--line); border-radius: 4px; }
.service { border-top: 1px solid var(--line); }
.service:first-child { border-top: 0; }
.service > summary { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; cursor: pointer; list-style: none; }
.service > summary::-webkit-details-marker { display: none; }
.service > summary:hover { background: var(--surface); }
.service > summary:focus-visible { outline: 1px solid var(--maintenance); outline-offset: -1px; }
.service-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.service-toggle { flex: 0 0 auto; width: 10px; color: var(--muted); font-size: 10px; transition: transform .15s ease; }
.service[open] .service-toggle { transform: rotate(90deg); }
.service-name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.service-status { color: var(--muted); font-size: 12px; white-space: nowrap; }
.service-elapsed { color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; }

/* タイムラインは1本の SVG（app.js の renderHistory）。幅いっぱいに伸縮する */
.history-strip { padding-left: 20px; }
.history-strip svg { display: block; width: 100%; height: 14px; }
.history-slot { fill: var(--line); }
.history-bar { fill: var(--unknown); }
.history-bar.status-operational { fill: var(--ok); }
.history-bar.status-degraded { fill: var(--degraded); }
.history-bar.status-outage { fill: var(--outage); }
.history-bar.status-maintenance { fill: var(--maintenance); }
.history-bar:hover { opacity: .75; }
.history-empty { margin: 0; padding-left: 20px; color: var(--muted); font-size: 12px; }
.service-list > .history-empty { padding: 12px 14px; }

.component-list { margin: 0; padding: 4px 14px 10px 34px; list-style: none; font-size: 12px; }
.component-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1px dashed var(--line); }
.component-row:first-child { border-top: 0; }
.component-row .dot { width: 6px; height: 6px; }
.component-key { font-family: var(--mono); }
.component-reason { color: var(--muted); }
.component-row.status-ng .component-reason { color: var(--outage); }
.component-empty { color: var(--muted); }

@media (max-width: 720px) {
  .topbar { gap: 12px; padding: 0 16px; }
  .content { padding: 12px 16px 24px; }
  .service-head { flex-wrap: wrap; row-gap: 2px; }
}
