:root {
  --accent: #F84617;
  --accent-ink: #fff;
  --bg: #f6f5f3;
  --surface: #fff;
  --surface-2: #f0eeeb;
  --ink: #1b1a19;
  --muted: #6d6964;
  --line: #e4e1dd;
  --danger: #c4231b;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 5%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1c1b1a;
    --surface-2: #262523;
    --ink: #f1efec;
    --muted: #a29d97;
    --line: #34322f;
    --danger: #ff6b5f;
    --ok: #4cc27f;
    --warn: #f0a63a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

/* An element's own display (the sign-in screen is a grid) mustn't beat hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

a { color: inherit; }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand img { border-radius: 7px; }

nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}

nav a {
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
}

nav a:hover { color: var(--ink); background: var(--surface-2); }
nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent); }

.server { color: var(--muted); font-size: 13px; white-space: nowrap; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

h1 { font-size: 26px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 28px 0 12px; }
h2:first-child { margin-top: 0; }

.muted { color: var(--muted); }
.error { color: var(--danger); }
.small { font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.list { display: grid; gap: 10px; }

.row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { color: var(--muted); font-size: 13px; }
.row .meta .warn, .row .meta.warn { color: var(--warn); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

button, .button {
  font: inherit;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

button:hover, .button:hover { border-color: var(--muted); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; }
button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

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

input, select {
  font: inherit;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }

.chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.chip.live { background: var(--danger); color: #fff; }
.chip.ok { color: var(--ok); }
.chip.warn { color: var(--warn); }
.chip.bad { color: var(--danger); }

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 6px;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 8px;
}

.bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.stat .value { font-size: 22px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; }

.filters { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.tile { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

.tile .art {
  aspect-ratio: 16 / 9;
  background: var(--surface-2) center / cover no-repeat;
  position: relative;
}

.tile .art .chip { position: absolute; left: 8px; top: 8px; }
.tile .body { padding: 12px; display: grid; gap: 4px; flex: 1; }
.tile .title { font-weight: 600; }
.tile .actions { justify-content: flex-start; padding: 0 12px 12px; }

.card.notice { border-color: var(--accent); margin-bottom: 16px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.day { color: var(--muted); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; margin: 20px 0 8px; }

.logs-tools { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.logs-tools input[type="search"] { flex: 1; min-width: 160px; }

pre.logs {
  margin: 0;
  padding: 14px;
  max-height: 70vh;
  overflow: auto;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

pre.logs .WARN { color: var(--warn); }
pre.logs .ERROR { color: var(--danger); }

.form { display: grid; gap: 16px; max-width: 560px; }
.form .help { font-weight: 400; color: var(--muted); font-size: 13px; }

.login {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 16px;
}

.login form { display: grid; gap: 14px; width: min(360px, 100%); text-align: center; }
.login img { margin: 0 auto; border-radius: 13px; }
.login h1 { margin: 0; }
.login label { text-align: left; }

dialog#player {
  width: min(960px, 96vw);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: #000;
  color: #fff;
  overflow: hidden;
}

dialog#player::backdrop { background: rgb(0 0 0 / 70%); }
.player-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 14px; }
.player-head .ghost { color: #fff; }
dialog video { display: block; width: 100%; max-height: 80vh; background: #000; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 20;
  max-width: calc(100vw - 32px);
}

@media (max-width: 720px) {
  .top { flex-wrap: wrap; gap: 8px; }
  nav { order: 3; flex-basis: 100%; }
  .server { margin-left: auto; }
  .row { flex-wrap: wrap; }
  .row .actions { width: 100%; justify-content: flex-start; }
}

.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.form label.check + .help { display: block; margin-top: 6px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
input:disabled, select:disabled { color: var(--muted); background: var(--surface-2); cursor: not-allowed; }
