:root {
  --bg: #f7f7fa;
  --surface: #ffffff;
  --surface-2: #f2f1f7;
  --line: #e4e3ec;
  --line-strong: #d0cfdc;
  --fg: #16151f;
  --fg-2: #4b4a5c;
  --fg-muted: #6e6c80;
  --brand: #6d28d9;
  --brand-fg: #ffffff;
  --brand-hover: #5b21b6;
  --focus: #6d28d9;

  --op: #22a35a;
  --op-text: #15803d;
  --deg: #e2b203;
  --deg-text: #946c00;
  --par: #f2780b;
  --par-text: #c2410c;
  --maj: #e5484d;
  --maj-text: #b91c1c;
  --mnt: #3b82f6;
  --mnt-text: #1d4ed8;
  --nodata: #d6d5df;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 21, 31, 0.06), 0 4px 16px rgba(22, 21, 31, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0c14;
    --surface: #16151f;
    --surface-2: #1f1e2b;
    --line: #2c2a3b;
    --line-strong: #3d3b50;
    --fg: #f3f2f8;
    --fg-2: #c9c7d6;
    --fg-muted: #9a98ab;
    --brand: #7c4ff0;
    --brand-fg: #ffffff;
    --brand-hover: #8f68f3;
    --focus: #b9a1ff;

    --op: #2fbf6c;
    --op-text: #4ade80;
    --deg: #e2b203;
    --deg-text: #facc15;
    --par: #f2780b;
    --par-text: #fb923c;
    --maj: #e5484d;
    --maj-text: #f87171;
    --mnt: #3b82f6;
    --mnt-text: #60a5fa;
    --nodata: #3a384a;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans", "Microsoft YaHei", sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

h1, h2, h3, h4 { line-height: 1.3; margin: 0; }
p { margin: 0; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; word-break: break-all; }

.container { width: 100%; max-width: 860px; margin: 0 auto; padding: 0 16px; }
.container.wide { max-width: 1120px; }
.main { padding-top: 32px; padding-bottom: 48px; }
.muted { color: var(--fg-muted); }
.small { font-size: 13px; }
.hint { color: var(--fg-muted); font-size: 13px; margin: 6px 0 12px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 72px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand img { display: block; height: 35px; width: auto; }
.brand-suffix { font-size: 18px; font-weight: 600; color: var(--fg-2); padding-left: 10px; border-left: 1px solid var(--line-strong); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--fg); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { background: var(--maj); border-color: var(--maj); color: #fff; }
.btn-danger:hover { background: var(--maj-text); border-color: var(--maj-text); }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--maj-text); }

/* Subscribe dropdown */
.subscribe { position: relative; }
.subscribe > summary { list-style: none; }
.subscribe > summary::-webkit-details-marker { display: none; }
.subscribe-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(360px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: grid; gap: 14px; font-size: 14px;
}
.subscribe-form { display: grid; gap: 10px; }
.subscribe-form input[type=email] { height: 38px; }
.feed-options { display: grid; gap: 6px; color: var(--fg-2); }
.feed-options code { font-size: 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Overall status banner */
.page-status {
  display: flex; align-items: center; gap: 14px; padding: 18px 22px; border-radius: var(--radius);
  color: #fff; margin-bottom: 24px; box-shadow: var(--shadow);
}
.page-status h1 { font-size: 20px; font-weight: 600; }
.page-status.st-operational { background: var(--op); }
.page-status.st-degraded-performance { background: var(--deg); color: #1d1600; }
.page-status.st-partial-outage { background: var(--par); }
.page-status.st-major-outage { background: var(--maj); }
.page-status.st-under-maintenance { background: var(--mnt); }
.page-status .status-icon { width: 24px; height: 24px; background: rgba(255, 255, 255, .25); }
.page-status .status-icon::after { border-color: currentColor; }

/* Status icon: a dot, with a tick for operational */
.status-icon {
  display: inline-block; flex: none; position: relative; width: 10px; height: 10px; border-radius: 50%;
  background: currentColor; vertical-align: middle; margin-right: 6px;
}
.page-status .status-icon { margin-right: 0; }
.page-status .status-icon::after {
  content: ""; position: absolute; left: 8px; top: 4px; width: 6px; height: 11px;
  border: solid currentColor; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.page-status:not(.st-operational) .status-icon::after { left: 10.75px; top: 5px; width: 0; height: 9px; border-width: 0 2.5px 0 0; transform: none; }

.status-text { font-size: 14px; font-weight: 500; white-space: nowrap; }
.status-text.st-operational { color: var(--op-text); }
.status-text.st-degraded-performance { color: var(--deg-text); }
.status-text.st-partial-outage { color: var(--par-text); }
.status-text.st-major-outage { color: var(--maj-text); }
.status-text.st-under-maintenance { color: var(--mnt-text); }

/* Incident / maintenance notices */
.notice {
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--fg-muted);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.notice-title { font-size: 17px; margin-bottom: 4px; }
.notice-title a { color: inherit; }
.notice-meta { color: var(--fg-muted); font-size: 13px; margin-bottom: 10px; }
.notice.impact-none { border-left-color: var(--fg-muted); }
.notice.impact-minor { border-left-color: var(--deg); }
.notice.impact-major { border-left-color: var(--par); }
.notice.impact-critical { border-left-color: var(--maj); }
.notice.impact-maintenance { border-left-color: var(--mnt); }

a.impact-minor, h1.impact-minor { color: var(--deg-text); }
a.impact-major, h1.impact-major { color: var(--par-text); }
a.impact-critical, h1.impact-critical { color: var(--maj-text); }
a.impact-maintenance, h1.impact-maintenance { color: var(--mnt-text); }
a.impact-none, h1.impact-none { color: var(--fg); }

/* Components */
.components { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 40px; }
.components-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.components-head h2 { font-size: 16px; }
.components-head .muted { font-size: 13px; }
.group { border-bottom: 1px solid var(--line); }
.group-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px 0; }
.group-head h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-muted); }
.component { padding: 14px 20px 16px; }
.component + .component { border-top: 1px dashed var(--line); }
.component-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.component-name { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.help {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%;
  border: 1px solid var(--line-strong); color: var(--fg-muted); font-size: 11px; font-weight: 600; cursor: help;
}

.bars { display: flex; gap: 2px; height: 34px; }
.bar { position: relative; flex: 1 1 0; min-width: 0; border-radius: 2px; background: var(--nodata); outline-offset: 1px; }
.bar.st-operational { background: var(--op); }
.bar.st-degraded-performance { background: var(--deg); }
.bar.st-partial-outage { background: var(--par); }
.bar.st-major-outage { background: var(--maj); }
.bar.st-under-maintenance { background: var(--mnt); }
.bar.st-no-data { background: var(--nodata); }
.bar:hover, .bar:focus { opacity: .75; }

.tip {
  display: none; position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
  width: 240px; z-index: 10; padding: 12px 14px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--fg); font-size: 13px; cursor: default;
}
.bar:hover .tip, .bar:focus .tip, .bar:focus-within .tip { display: block; }
.tip-date { font-weight: 600; margin-bottom: 4px; }
.tip-detail { color: var(--fg-2); }
.tip-incidents { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px solid var(--line); display: grid; gap: 4px; }

.bars-footer { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; white-space: nowrap; }
.bars-footer .rule { flex: 1; height: 1px; background: var(--line); }

.days-60, .days-30 { display: none; }
@media (max-width: 900px) {
  .bar.o60 { display: none; }
  .days-full { display: none; }
  .days-60 { display: inline; }
}
@media (max-width: 600px) {
  .bar.o30 { display: none; }
  .days-60 { display: none; }
  .days-30 { display: inline; }
}

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; list-style: none; margin: 0; padding: 14px 20px; font-size: 12px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch.st-operational { background: var(--op); }
.swatch.st-degraded-performance { background: var(--deg); }
.swatch.st-partial-outage { background: var(--par); }
.swatch.st-major-outage { background: var(--maj); }
.swatch.st-under-maintenance { background: var(--mnt); }
.swatch.st-no-data { background: var(--nodata); }

/* Past incidents */
.past > h2, .history h1 { font-size: 22px; margin-bottom: 16px; }
.day { padding: 16px 0; border-top: 1px solid var(--line); }
.day h3 { font-size: 15px; margin-bottom: 8px; color: var(--fg-2); }
.incident-summary + .incident-summary { margin-top: 16px; }
.incident-summary h4 { font-size: 16px; margin-bottom: 6px; }
.schedule { color: var(--fg-muted); font-size: 13px; margin-bottom: 8px; }
.updates { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.update-body { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--fg-2); }
.update-body strong { color: var(--fg); }
.update-time { color: var(--fg-muted); font-size: 12px; margin-top: 2px; }
.history-link { margin-top: 20px; }

/* Incident page */
.crumbs { color: var(--fg-muted); font-size: 13px; margin-bottom: 10px; }
.incident-page h1 { font-size: 26px; margin-bottom: 8px; }
.timeline { list-style: none; margin: 24px 0; padding: 0; }
.timeline-row { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.timeline-status { font-weight: 700; }
.affected { color: var(--fg-muted); font-size: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 600px) {
  .timeline-row { grid-template-columns: 1fr; gap: 4px; }
}

/* History */
.month { margin-bottom: 28px; }
.month h2 { font-size: 17px; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.history-item { padding: 10px 0; }
.history-item h3 { font-size: 15px; margin-bottom: 4px; }
.pager { display: flex; justify-content: space-between; margin-top: 16px; }

/* Message pages */
.message-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.message-box h1 { font-size: 22px; }
.message-box form { margin: 0; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 24px 0 32px; font-size: 13px; }
.footer-inner { display: grid; gap: 10px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* Forms (shared by subscribe and admin) */
input, select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 25%, transparent); }
textarea { resize: vertical; min-height: 80px; }
input[type=checkbox] { width: auto; }

/* Admin */
.admin .main { display: grid; gap: 20px; align-content: start; }
.admin .page-status { margin-bottom: 0; }
.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 14px; }
.admin-nav form { margin: 0; }
.admin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card.narrow { max-width: 420px; margin: 40px auto; width: 100%; }
.card h1 { font-size: 22px; margin-bottom: 6px; }
.card h2 { font-size: 17px; margin-bottom: 12px; }
.form { display: grid; gap: 8px; }
.form label { font-weight: 600; font-size: 13px; margin-top: 6px; }
.form label.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-row > div { display: grid; gap: 8px; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.picker { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 8px 0 0; min-width: 0; }
.picker legend { font-weight: 600; font-size: 13px; padding: 0 4px; }
.picker select { max-width: 240px; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-muted); font-weight: 600; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); color: var(--fg-2); border: 1px solid var(--line); vertical-align: middle; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; }
.alert-ok { background: color-mix(in srgb, var(--op) 14%, var(--surface)); color: var(--op-text); border: 1px solid color-mix(in srgb, var(--op) 40%, transparent); }
.alert-error { background: color-mix(in srgb, var(--maj) 12%, var(--surface)); color: var(--maj-text); border: 1px solid color-mix(in srgb, var(--maj) 40%, transparent); }
.inline-edit { margin-top: 6px; font-size: 13px; }
.inline-edit summary { cursor: pointer; color: var(--fg-muted); }
.inline-edit .form { margin-top: 8px; }
.danger-zone { border-color: color-mix(in srgb, var(--maj) 35%, var(--line)); }
.danger-zone form { margin-top: 12px; }

@media (max-width: 600px) {
  .main { padding-top: 20px; }
  .header-inner { min-height: 60px; }
  .brand img { height: 28px; }
  .brand-suffix { font-size: 16px; }
  .page-status { padding: 14px 16px; }
  .page-status h1 { font-size: 17px; }
  .components-head, .group-head, .component, .legend { padding-left: 14px; padding-right: 14px; }
  .bars { height: 30px; gap: 2px; }
  .subscribe-panel { right: auto; left: 0; }
  .incident-page h1 { font-size: 22px; }
}
