/* OGA Status — styles (SPEC §9). Mobile first, light + dark via prefers-color-scheme.
   All colour pairs are checked for WCAG AA: text >= 4.5:1, status colours >= 4.5:1 on both
   page and card backgrounds, bar fills / focus ring / control borders >= 3:1. */

:root {
  color-scheme: light dark;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --hover: #eceef1;
  --text: #1c2026;
  --muted: #4f5761;
  --border: #d5d9de;
  --control-border: #7a828c;
  --link: #0b57d0;
  --focus: #0b57d0;
  --accent: #2a6fc9;
  --grid: #e3e6ea;
  --axis: #8b929b;
  --skeleton: #e6e8eb;
  --brand: #1c2026;
  --brand-ink: #ffffff;
  --on-status: #ffffff;
  --shadow: 0 8px 24px rgb(16 24 40 / 0.16);
  /* status colours (text, icons, banners, bars) */
  --op: #1b7a3d;
  --dp: #8a6400;
  --po: #b94a00;
  --mo: #9d1036;
  --nd: #5e6670;
  --nd-fill: #8b929b;
  --mt: #0b57d0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #191d23;
    --hover: #232831;
    --text: #e7e9ec;
    --muted: #a9b0b9;
    --border: #333a44;
    --control-border: #7d8590;
    --link: #8ab4f8;
    --focus: #8ab4f8;
    --accent: #6aa5f5;
    --grid: #2a3038;
    --axis: #6e7781;
    --skeleton: #262b33;
    --brand: #e7e9ec;
    --brand-ink: #191d23;
    --on-status: #111418;
    --shadow: 0 8px 24px rgb(0 0 0 / 0.5);
    --op: #4cc27a;
    --dp: #e3b341;
    --po: #f0883e;
    --mo: #f85149;
    --nd: #9aa3ad;
    --nd-fill: #6e7781;
    --mt: #8ab4f8;
  }
}

/* ---------------------------------------------------------------- base */

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

h1, h2, h3 { line-height: 1.4; font-weight: 600; }
p { margin: 0 0 0.5rem; }
img, svg { max-width: 100%; }

.wrap {
  width: 100%;
  max-width: 52rem;
  margin-inline: auto;
  padding-inline: 16px;
}

.vh {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Visible keyboard focus everywhere (never removed). */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.link {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* Stand-alone links get a >= 44 px tall hit area. */
.card__link .link,
.site-footer .link,
.dinc .link,
.active__title {
  display: inline-block;
  padding-block: 0.5625rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--control-border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
}
.btn--small { padding: 0.375rem 0.75rem; }
.btn:active:not(:disabled) { transform: translateY(1px); background: var(--hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn[aria-disabled="true"] { cursor: progress; }

@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--hover); }
  .link:hover { text-decoration-thickness: 2px; }
}

/* ---------------------------------------------------------------- status tokens & icons */

[data-state="op"] { --c: var(--op); --h: 55%; }
[data-state="dp"] { --c: var(--dp); --h: 70%; }
[data-state="po"] { --c: var(--po); --h: 85%; }
[data-state="mo"] { --c: var(--mo); --h: 100%; }
[data-state="nd"] { --c: var(--nd); --h: 22%; }
[data-state="mt"] { --c: var(--mt); --h: 22%; }
[data-state="pl"] { --c: var(--muted); }
[data-state="loading"] { --c: var(--muted); }

.ico {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  vertical-align: -0.2em;
}
.ico__shape { fill: currentColor; }
.ico__glyph { stroke: var(--glyph, var(--surface)); }
.ico__line { stroke: currentColor; }

.state {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--c, var(--text));
  font-weight: 600;
  white-space: normal;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.0625rem 0.625rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.6;
}
.badge[data-state] { color: var(--c); }
.badge--ok { color: var(--op); }
.badge--open { color: var(--text); border-width: 2px; }
.badge--plain { color: var(--muted); border-color: var(--border); }

/* ---------------------------------------------------------------- header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header__inner { padding-block: 1rem; }
.site-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0;
  font-size: 1.5rem;
}
.site-title__mark { width: 2rem; height: 2rem; flex: none; }
.mark-bg { fill: var(--brand); }
.mark-fg { stroke: var(--brand-ink); }
.site-sub { margin: 0.25rem 0 0; color: var(--muted); }

/* ---------------------------------------------------------------- overview */

.banner {
  --glyph: var(--c);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 4.75rem;
  margin: 1.5rem 0 0.75rem;
  padding: 1rem 1.25rem;
  border: 1px solid transparent;
  border-radius: 0.75rem;
  background: var(--c);
  color: var(--on-status);
}
.banner[data-state="loading"] {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.banner__icon { display: flex; flex: none; }
.banner__icon:empty { display: none; }
.banner .ico { width: 1.75rem; height: 1.75rem; }
.banner__text { margin: 0; font-size: 1.25rem; font-weight: 600; line-height: 1.5; }
/* Narrow screens: every real message wraps to two lines, so two lines are reserved from the start
   (the "loading" banner is as tall as the data banner: no layout shift when the summary arrives). */
@media (max-width: 36em) {
  .banner { min-height: 5.5rem; padding-inline: 1rem; }
  .banner__text { font-size: 1.125rem; }
}

.meta-line { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.875rem; }
/* "--:--" and "14:05" take the same width, so the line never re-wraps when the time arrives */
.hhmm { display: inline-block; min-width: 5ch; font-variant-numeric: tabular-nums; text-align: center; }

.notice {
  margin: 0.75rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}
.notice--error { border-color: var(--mo); border-left-width: 0.375rem; }
.notice--info { border-color: var(--mt); border-left-width: 0.375rem; }
.notice--plain { color: var(--muted); }
.notice__text { margin: 0; flex: 1 1 16rem; }
#fetch-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
/* A failed background poll while data is on screen (app.js sets .notice--toast): the notice floats at the bottom of
   the viewport instead of pushing the page down (no layout shift). Its height is capped (it scrolls inside beyond
   that, e.g. at 400 % zoom), and html.has-toast reserves the same space at the end of the page and for keyboard
   scrolling, so neither the footer links nor a focused control stay hidden under it. */
:root { --toast-max: min(45vh, 15rem); }
@media (min-width: 48em) { :root { --toast-max: min(45vh, 10rem); } } /* one or two lines beside the button */
#fetch-error.notice--toast {
  position: fixed;
  z-index: 10;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: calc(52rem - 32px);
  max-height: var(--toast-max);
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow);
}
html.has-toast { scroll-padding-bottom: calc(var(--toast-max) + 32px); }
html.has-toast .site-footer { padding-bottom: calc(2.5rem + var(--toast-max) + 16px); }

/* first child of #bots: same top margin as the skeleton / bot card it sits above, so #bots does not move */
.active {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-left: 0.375rem solid var(--text);
  border-radius: 0.75rem;
  background: var(--surface);
}
.active__h {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1rem;
}
.active__list { list-style: none; margin: 0; padding: 0; }
.active__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.75rem;
}
.active__title { font-weight: 600; }
.active__meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ---------------------------------------------------------------- cards */

.card {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface);
}
@media (min-width: 40em) {
  .card { padding: 1.5rem; }
}
.card__title { margin: 0 0 0.25rem; font-size: 1.25rem; }
.card__lead { margin: 0 0 1rem; color: var(--muted); max-width: 42em; }
.card__link { margin: 0.5rem 0 0; }
.sub-h { margin: 1.25rem 0 0.25rem; font-size: 1rem; }
.placeholder { margin: 0; color: var(--muted); list-style: none; }

/* skeleton shown until the first summary arrives (same footprint as a bot card) */
/* (measured with the dev sample: a 5-component bot card is ~1280 px at 360 px, ~1180 px at 480 px, 1135 px from 640 px) */
.skeleton { min-height: 80rem; }
@media (min-width: 30em) { .skeleton { min-height: 74rem; } }
@media (min-width: 40em) { .skeleton { min-height: 71rem; } }
.skeleton > div { border-radius: 0.5rem; background: var(--skeleton); }
.skeleton__title { height: 1.75rem; width: 55%; }
.skeleton__banner { height: 3.25rem; margin: 1rem 0; }
.skeleton__row { height: 5.75rem; margin-top: 1rem; }
/* planned target card (title +「準備中」+ one line) */
.skeleton--planned { min-height: 7rem; }
@media (min-width: 30em) { .skeleton--planned { min-height: 6rem; } }
@media (min-width: 40em) { .skeleton--planned { min-height: 7rem; } }

/* ---------------------------------------------------------------- bot group */

.gbanner {
  --glyph: var(--surface);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin: 0.75rem 0 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--c);
  border-left-width: 0.375rem;
  border-radius: 0.5rem;
  background: var(--surface);
  background: color-mix(in srgb, var(--c) 8%, var(--surface));
  color: var(--text);
}
.gbanner .ico { width: 1.5rem; height: 1.5rem; color: var(--c); }
.gbanner__text { margin: 0; font-weight: 600; }

.comps { list-style: none; margin: 0; padding: 0; }
.comp { padding: 0.875rem 0; border-top: 1px solid var(--border); }
.comp:first-child { border-top: 0; }
.comp__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.125rem 0.75rem;
  margin-bottom: 0.375rem;
}
.comp__name { min-width: 0; font-weight: 600; }
.comp--group .comp__name { font-weight: 600; }
.comp__note { margin: -0.125rem 0 0.5rem; }
.comp--ref {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.125rem 0.75rem;
  padding: 0.625rem 0;
}

/* 90-day bar: one <button> per day. Colour AND height encode the state. */
.ubar { position: relative; }
.ubar__cells {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 2.75rem;
}
@media (min-width: 30em) { .ubar__cells { gap: 1px; } }
@media (min-width: 48em) { .ubar__cells { gap: 2px; } }
.day {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.day::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--h, 55%);
  border-radius: 2px 2px 0 0;
  background: var(--c);
}
.day[data-state="nd"],
.legend__sw[data-state="nd"] { --c: var(--nd-fill); }
.day.is-sel { z-index: 1; outline: 2px solid var(--text); outline-offset: 2px; }
.day:focus-visible { z-index: 2; outline: 3px solid var(--focus); outline-offset: 2px; }
.ubar__empty { margin: 0; align-self: center; color: var(--muted); }

.ubar__panel {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--control-border);
  border-radius: 0.75rem;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.dpanel__date { margin: 0 0 0.25rem; font-weight: 600; }
.dpanel__nodata { margin: 0 0 0.5rem; }
.dpanel__list { display: grid; gap: 0.125rem; margin: 0 0 0.5rem; }
.dpanel__list > div { display: flex; flex-wrap: wrap; gap: 0 0.75rem; }
.dpanel__list dt { color: var(--muted); }
.dpanel__list dd { margin: 0; font-weight: 600; }
.dpanel__nav { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.ubar__caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 0.5rem;
  margin-top: 0.375rem;
  color: var(--muted);
  font-size: 0.875rem;
}
.ubar__uptime { color: var(--text); font-weight: 600; }

.legend {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}
.legend__title { margin: 0 0 0.5rem; color: var(--text); font-weight: 600; }
.legend__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.legend__item { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--text); }
.legend__sw { position: relative; flex: none; width: 0.5rem; height: 1.25rem; }
.legend__sw::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--h);
  border-radius: 2px 2px 0 0;
  background: var(--c);
}
.legend__hint { margin: 0.5rem 0 0; }

.empty p { margin: 0.5rem 0 0; color: var(--muted); }

/* planned target (Amendment A2): neutral「準備中」label (icon + text), no status colours */
.bot__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
}
.bot__head .card__title { margin: 0; }
.planned__text { margin: 0.5rem 0 0; color: var(--muted); }

/* ---------------------------------------------------------------- Discord */

.dinc { list-style: none; margin: 0; padding: 0; }
.dinc__item { padding: 0.75rem 0 0.25rem; border-top: 1px solid var(--border); }
.dinc__name { margin: 0; font-weight: 600; }
.dinc__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}
.dinc__item p { margin-bottom: 0; }

/* ---------------------------------------------------------------- response-time charts */

.seg { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.seg-field { margin-bottom: 0.5rem; }
.seg-field__label { margin: 0 0 0.25rem; color: var(--muted); font-size: 0.875rem; font-weight: 600; }
/* the BOT buttons arrive with the data: reserve their rows (2 on phones, where the long names wrap) */
.seg--bots { min-height: 6rem; align-content: flex-start; }
@media (min-width: 30em) { .seg--bots { min-height: 2.75rem; } }
.seg__single { display: flex; align-items: center; min-height: 2.75rem; margin: 0; font-weight: 600; }
.seg__btn[aria-pressed="true"],
.seg__btn[aria-pressed="true"]:hover,
.seg__btn[aria-pressed="true"]:active { background: var(--text); border-color: var(--text); color: var(--surface); }
.seg__btn[aria-pressed="true"]::before { content: "✓"; content: "✓" / ""; }

.rt-charts { min-height: 37rem; }
.chart { margin: 1rem 0 0; }
.chart__title { font-weight: 600; }
.chart__readout {
  min-height: 1.7em;
  margin: 0.125rem 0 0.25rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart__rval { color: var(--text); }
.chart__plot {
  position: relative;
  height: 180px;
  border-radius: 0.375rem;
  touch-action: pan-y;
  cursor: crosshair;
  overflow: hidden;
}
.chart__svg { display: block; width: 100%; height: 100%; }
.chart__grid { stroke: var(--grid); stroke-width: 1; }
.chart__axis { stroke: var(--axis); stroke-width: 1; }
.chart__tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart__line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__pt { fill: var(--accent); }
.chart__dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart__x { display: none; }
.chart__x.is-on { display: inline; }
.chart__xline { stroke: var(--muted); stroke-width: 1; }
.chart__dot.is-hidden { display: none; }
.chart__empty {
  display: grid;
  place-items: center;
  height: 100%;
  margin: 0;
  border: 1px dashed var(--border);
  border-radius: 0.375rem;
  color: var(--muted);
}
.chart__summary { margin: 0.25rem 0 0; color: var(--muted); }

/* ---------------------------------------------------------------- history */

.history { margin: 0; padding: 0; list-style: none; }
.history--archive { margin-top: 0; border-top: 1px solid var(--border); }
.inc { padding: 1rem 0; border-top: 1px solid var(--border); }
.history > li:first-child { border-top: 0; }
.inc:target { box-shadow: inset 0.25rem 0 0 var(--focus); padding-left: 0.875rem; }
.inc__title { margin: 0 0 0.375rem; font-size: 1rem; }
.inc__badges { display: flex; flex-wrap: wrap; gap: 0.375rem; margin: 0 0 0.5rem; }
.inc__meta { display: grid; gap: 0.125rem; margin: 0 0 0.75rem; }
.inc__meta > div { display: flex; gap: 0.75rem; }
.inc__meta dt { flex: none; min-width: 2.5em; color: var(--muted); }
.inc__meta dd { margin: 0; min-width: 0; }

.updates {
  margin: 0;
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--border);
  list-style: none;
}
.upd { position: relative; padding-bottom: 0.75rem; }
.upd:last-child { padding-bottom: 0; }
.upd::before {
  content: "";
  position: absolute;
  top: 0.55em;
  left: calc(-1rem - 6px);
  width: 10px;
  height: 10px;
  border: 2px solid var(--control-border);
  border-radius: 50%;
  background: var(--surface);
}
.upd__head { margin: 0; color: var(--muted); }
.upd__status { color: var(--text); }
.upd__body { margin: 0.125rem 0 0; white-space: pre-line; }
.inc__more { margin-top: 0.75rem; }
.inc__more-status { margin: 0.25rem 0 0; color: var(--muted); }
.inc__more-status:empty { display: none; }

.ev {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}
.ev .ico { margin-top: 0.3em; }
.ev__text { margin: 0; }
.history__empty { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; color: var(--text); }
.history__empty .ico { color: var(--op); }
.archive-status { margin: 0.75rem 0 0.5rem; color: var(--muted); }
.archive-status:empty { margin: 0.25rem 0; }

/* ---------------------------------------------------------------- footer */

.site-footer {
  margin-top: 2rem;
  padding: 1.25rem 0 2.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.site-footer__inner p { margin: 0; }

/* ---------------------------------------------------------------- Windows high contrast */

@media (forced-colors: active) {
  .day::after,
  .legend__sw::after { forced-color-adjust: none; background: CanvasText; }
  .day[data-state="nd"]::after,
  .legend__sw[data-state="nd"]::after { background: GrayText; }
  .banner, .gbanner { border: 2px solid CanvasText; }
}
