/* =========================================================
   Theme tokens
   ========================================================= */
:root,
[data-theme="light"] {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #f1f4ef;
  --border: #e3e8e0;
  --text: #1b1f1c;
  --text-muted: #69736b;
  --accent: #3f9d4a;
  --accent-soft: rgba(63, 157, 74, 0.12);
  --accent-chart: #4caf50;
  --warn: #c98a0c;
  --warn-soft: rgba(201, 138, 12, 0.12);
  --danger: #d6453d;
  --danger-soft: rgba(214, 69, 61, 0.12);
  --shadow: 0 1px 2px rgba(20, 30, 20, 0.04), 0 8px 24px rgba(20, 30, 20, 0.06);
  --header-bg: rgba(244, 246, 243, 0.82);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #16181c;
  --surface: #1f2227;
  --surface-2: #262a30;
  --border: #2d3137;
  --text: #e9ece8;
  --text-muted: #8e978f;
  --accent: #4ade80;
  --accent-soft: rgba(74, 222, 128, 0.12);
  --accent-chart: #4ade80;
  --warn: #facc15;
  --warn-soft: rgba(250, 204, 21, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --header-bg: rgba(22, 24, 28, 0.82);
  color-scheme: dark;
}

:root {
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --header-h: 64px;
  --font: "Inter", "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", sans-serif;
}

/* =========================================================
   Base
   ========================================================= */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  padding: 8px 14px;
  background: var(--accent);
  color: #0b1a0f;
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* =========================================================
   Header
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  max-width: 1360px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand__mark {
  width: 30px;
  height: 30px;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand__leaf { fill: var(--accent-soft); }

.brand__type {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand__type-sub {
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin-left: 2px;
}

.global-nav { margin-left: auto; overflow-x: auto; }
.global-nav ul {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.global-nav a {
  display: block;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.global-nav a:hover { color: var(--text); }
.global-nav a.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.15s ease;
}
.theme-toggle:hover { transform: rotate(-12deg); }
.theme-toggle .icon--moon { display: none; }
[data-theme="dark"] .theme-toggle .icon--sun { display: none; }
[data-theme="dark"] .theme-toggle .icon--moon { display: block; }

/* =========================================================
   Layout
   ========================================================= */
.layout {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px 12px;
}
.sidebar__title {
  margin: 0 8px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.server-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.server-list__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.server-list__item:hover { background: var(--surface-2); }
.server-list__item[aria-current="true"] { background: var(--accent-soft); }
.server-list__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-list__meta { font-size: 12px; color: var(--text-muted); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
[data-state="online"] .dot,
.dot[data-state="online"] {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
[data-state="offline"] .dot,
.dot[data-state="offline"] {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.main { min-width: 0; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head__eyebrow { margin: 0; font-size: 13px; color: var(--text-muted); }
.page-head__title {
  margin: 2px 0 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.page-head__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.updated { font-size: 13px; color: var(--text-muted); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.status-pill[data-state="online"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.status-pill[data-state="offline"] { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost .icon { width: 15px; height: 15px; }
.btn-ghost.is-loading .icon { animation: spin 0.8s linear infinite; }
.btn-ghost--sm { padding: 3px 10px; font-size: 12px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   Cards
   ========================================================= */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  min-width: 0;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}
.card--tps { grid-column: span 8; }
.card--info { grid-column: span 4; }
.card--chart { grid-column: span 8; }
.card--memory { grid-column: span 4; display: flex; flex-direction: column; }
.card--log { grid-column: span 12; }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card__title { margin: 0; font-size: 15px; font-weight: 600; }
.card__hint { font-size: 12px; color: var(--text-muted); }

/* TPS */
.tps-values {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 12px;
}
.tps-value {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
}
.tps-value__label { font-size: 12px; color: var(--text-muted); }
.tps-value__num {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.tps-value--primary .tps-value__num { font-size: 44px; }
.tps-value__num[data-level="good"] { color: var(--accent); }
.tps-value__num[data-level="warn"] { color: var(--warn); }
.tps-value__num[data-level="bad"] { color: var(--danger); }

.card--tps { display: flex; flex-direction: column; }
.tps-health { margin-top: auto; padding-top: 20px; }
.tps-health__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}
.tps-health__label { color: var(--text-muted); }
.tps-health__state { font-weight: 600; }
.tps-health__state[data-level="good"] { color: var(--accent); }
.tps-health__state[data-level="warn"] { color: var(--warn); }
.tps-health__state[data-level="bad"] { color: var(--danger); }
.tps-health__bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.tps-health__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.3s ease;
}
.tps-health__fill[data-level="warn"] { background: var(--warn); }
.tps-health__fill[data-level="bad"] { background: var(--danger); }

/* Info */
.info-list { margin: 0; display: grid; gap: 2px; }
.info-list__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.info-list__row:last-child { border-bottom: 0; }
.info-list dt { font-size: 13px; color: var(--text-muted); }
.info-list dd { margin: 0; font-size: 14px; font-weight: 600; text-align: right; overflow-wrap: anywhere; }

.state-badge {
  display: inline-flex;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
}
.state-badge[data-state="online"] { background: var(--accent-soft); color: var(--accent); }
.state-badge[data-state="offline"] { background: var(--danger-soft); color: var(--danger); }

.player-chips {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.player-chips li {
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.player-chips .is-empty { background: transparent; border-style: dashed; color: var(--text-muted); }

/* Chart */
.chart { position: relative; height: 240px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.chart__grid { stroke: var(--border); stroke-width: 1; }
.chart__axis { fill: var(--text-muted); font-size: 11px; font-family: var(--font); }
.chart__line { fill: none; stroke: var(--accent-chart); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart__point { fill: var(--surface); stroke: var(--accent-chart); stroke-width: 2; }
.chart__cursor { stroke: var(--text-muted); stroke-dasharray: 3 3; }

.chart-tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px));
  font-variant-numeric: tabular-nums;
}

/* Memory ring */
.ring { position: relative; width: 168px; height: 168px; margin: 4px auto 0; }
.ring__svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__track { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.ring__bar {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 314.16;
  stroke-dashoffset: 314.16;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.3s ease;
}
.ring__bar[data-level="warn"] { stroke: var(--warn); }
.ring__bar[data-level="bad"] { stroke: var(--danger); }
.ring__label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring__pct { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.ring__sub { font-size: 12px; color: var(--text-muted); }
.mem-detail { margin: 14px 0 0; text-align: center; font-size: 13px; color: var(--text-muted); }

/* Event log */
.event-log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  display: grid;
  gap: 2px;
}
.event-log li {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.event-log li:nth-child(odd) { background: var(--surface-2); }
.event-log time { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.event-log .tag {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}
.event-log .tag[data-kind="warn"] { background: var(--warn-soft); color: var(--warn); }
.event-log .tag[data-kind="error"] { background: var(--danger-soft); color: var(--danger); }
.event-log .is-empty { color: var(--text-muted); grid-template-columns: 1fr; }
.event-log .msg { overflow-wrap: anywhere; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1080px) {
  .grid { grid-auto-flow: dense; }  /* 追加：空いた隙間にメモリカードを詰める */
  .card--tps, .card--chart { grid-column: span 12; }
  .card--info, .card--memory { grid-column: span 6; }
}ss

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; padding-top: 16px; }
  .sidebar { position: static; padding: 14px 10px; }
  .server-list { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .brand__type-sub { display: none; }
}

@media (max-width: 620px) {
  .site-header__inner { gap: 12px; padding: 0 14px; }
  .brand__type { display: none; }
  .global-nav a { padding: 6px 12px; font-size: 13px; }
  .card--info, .card--memory { grid-column: span 6; padding: 14px; }  /* span 12 → span 6 */
  .grid { gap: 12px; }
  .tps-values { grid-template-columns: 1fr 1fr; }
  .tps-value--primary { grid-column: span 2; }
  .page-head__title { font-size: 24px; }
  .event-log li { grid-template-columns: auto 1fr; }
  .event-log .msg { grid-column: span 2; }

  /* 半幅に収めるための縮小 */
  .ring { width: 100%; max-width: 130px; height: auto; aspect-ratio: 1; }
  .ring__pct { font-size: 22px; }
  .mem-detail { font-size: 11px; }
  .info-list__row { flex-wrap: wrap; gap: 4px; }
  .info-list dd { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

