/* Relay design system — mobile-first. No external URLs. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #142033;
  --muted: #5b6b82;
  --border: #d5dde8;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --ok: #1f9d63;
  --warn: #c47b16;
  --danger: #c43737;
  --chip-unregistered: #8a93a3;
  --chip-registered: #2f6fed;
  --chip-connected-read: #1a9b8e;
  --chip-connected-propose: #c47b16;
  --chip-connected-execute: #1f9d63;
  --chip-paused: #c43737;
  --chip-retired: #8a93a3;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --appbar-h: 56px;
  --tabbar-h: calc(56px + var(--safe-bottom));
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 32, 51, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141d;
    --surface: #172131;
    --surface-2: #1e2a3d;
    --text: #e8eef8;
    --muted: #9aabc2;
    --border: #2c3a50;
    --accent: #5b8ff5;
    --accent-ink: #0e141d;
    --ok: #3dce8a;
    --warn: #e0a045;
    --danger: #ef6b6b;
    --chip-unregistered: #7a8496;
    --chip-registered: #5b8ff5;
    --chip-connected-read: #3dbdb0;
    --chip-connected-propose: #e0a045;
    --chip-connected-execute: #3dce8a;
    --chip-paused: #ef6b6b;
    --chip-retired: #7a8496;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
  max-width: 100vw;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.app-shell {
  min-height: 100dvh;
  padding-top: var(--appbar-h);
  padding-bottom: var(--tabbar-h);
}

.main {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
}

.appbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.appbar__title {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
}

.appbar__user {
  color: var(--muted);
  font-size: 0.875rem;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: var(--tabbar-h);
  padding-bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tabbar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  min-height: 44px;
}

.tabbar__item.is-active {
  color: var(--accent);
  font-weight: 700;
}

.tabbar__item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin: 0 0 0.75rem;
}

.card__title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.card__sub {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: var(--chip-unregistered);
}

.chip--registered { background: var(--chip-registered); }
.chip--connected-read { background: var(--chip-connected-read); }
.chip--connected-propose { background: var(--chip-connected-propose); }
.chip--connected-execute { background: var(--chip-connected-execute); }
.chip--paused { background: var(--chip-paused); }
.chip--retired,
.chip--unregistered { background: var(--chip-unregistered); }
.chip--muted {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.monitor-banner {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.monitor-banner--stale,
.monitor-banner--unknown {
  border-color: var(--warn);
}
.monitor-banner--alerts {
  border-color: var(--danger);
}
.monitor-banner ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}
.monitor-banner__note {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.chip--ok { background: var(--ok); }
.chip--warn { background: var(--warn); }
.chip--danger { background: var(--danger); }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list__item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin: 0 0 0.6rem;
}

.list__primary {
  font-weight: 600;
  margin: 0 0 0.2rem;
}

.list__secondary {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn--block {
  width: 100%;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.page-title {
  margin: 0;
  font-size: 1.25rem;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.skeleton {
  border-radius: var(--radius);
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  min-height: 72px;
  margin-bottom: 0.75rem;
}

@keyframes skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.form {
  display: grid;
  gap: 0.85rem;
}

.form label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.form input {
  min-height: 44px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.form__error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
}

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-card {
  width: min(100%, 420px);
}

.offline-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
}
