:root {
  color-scheme: dark;
  font-family: "Segoe UI", Inter, sans-serif;
  background: #0c1117;
  color: #edf2f7;
  --muted: #9aa8b8;
  --line: rgba(255, 255, 255, 0.16);
  --gap: 16px;
  --tile: 390px;
  --page: 24px;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  width: min(100% - 2 * var(--page), calc(4 * var(--tile) + 3 * var(--gap)));
  margin: 0 auto;
  padding: 16px 0 8px;
}
h1 { font-size: clamp(1.25rem, 2vw, 1.6rem); font-weight: 500; }
.host, .login-host { color: var(--muted); font-size: 0.9rem; }
.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.counts, .services, .cycle { color: var(--muted); font-size: 0.9rem; }
.topbar button, .dialog-actions button, .login-card button {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: #243140;
  color: inherit;
}
.login-card button, .dialog-actions button[type="submit"] { background: #1d4e89; color: #fff; }

.banner {
  width: min(100% - 2 * var(--page), calc(4 * var(--tile) + 3 * var(--gap)));
  margin: 8px auto 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: #8a6a12;
  color: #1c1404;
}

.tiles {
  width: min(100% - 2 * var(--page), calc(4 * var(--tile) + 3 * var(--gap)));
  margin: 12px auto 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--tile), 100%), 1fr));
  gap: var(--gap);
}

.tile {
  min-width: 0;
  padding: 14px 16px 16px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tile--red { background: #8f2433; color: #fff; }
.tile--yellow { background: #f0c14b; color: #1c1404; }
.tile--green { background: #157347; color: #fff; }
.tile--blue { background: #1d4e89; color: #fff; }
.tile--gray { background: #3a4350; color: #e8edf2; }
.tile-stale { outline: 2px dashed var(--line); outline-offset: -6px; }

.tile-head, .stream {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.tile-head h2 { font-size: 1.25rem; font-weight: 500; }
.badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.85rem;
}
.muted { color: inherit; opacity: 0.82; font-size: 0.88rem; }
.file-label { font-size: 1.05rem; font-weight: 500; }
.streams { display: flex; flex-direction: column; gap: 8px; }
.stream { flex-wrap: wrap; }
.stream b { font-weight: 500; }
.bar {
  height: 6px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.bar > span { display: block; height: 100%; background: currentColor; }
.tile-error {
  margin: 0;
  white-space: pre-wrap;
  max-height: 8em;
  overflow: auto;
  font-size: 0.88rem;
}
.notice { font-size: 0.95rem; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%);
  padding: 28px;
  border-radius: 14px;
  background: #1b2430;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-card input, dialog input {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #3a4452;
  background: #11151a;
  color: inherit;
}
.login-card button { margin-top: 12px; }
.error { color: #ffb4bc; min-height: 1.2em; }
.error:empty { display: none; }
.tile--yellow .error, .tile--red .tile-error { color: inherit; }

dialog {
  width: min(420px, calc(100% - 24px));
  border: 0;
  border-radius: 14px;
  padding: 20px;
  background: #1b2430;
  color: inherit;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog form { display: flex; flex-direction: column; gap: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

@media (max-width: 420px) {
  :root { --page: 12px; }
  .topbar button { padding: 8px 10px; }
}
