/* 8star Stream admin. Works on desktop and tablet; light and dark mode. */
:root {
  --bg: #f5f5f7;
  --panel: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #d9d9de;
  --accent: #c8102e;
  --accent-text: #ffffff;
  --ok: #1b7f3b;
  --ok-bg: #e3f4e8;
  --bad: #b3261e;
  --bad-bg: #fde7e6;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --info: #0b5cad;
  --info-bg: #e2eefb;
  --field-bg: #fff;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114;
    --panel: #1c1c20;
    --text: #f2f2f5;
    --muted: #a1a1aa;
    --line: #34343b;
    --ok: #6fd68f;
    --ok-bg: #173323;
    --bad: #ff8a80;
    --bad-bg: #3a1716;
    --warn: #ffcc66;
    --warn-bg: #3a2e12;
    --info: #8cc1ff;
    --info-bg: #142a44;
    --field-bg: #16161a;
    color-scheme: dark;
  }
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a {
  color: var(--info);
}
h1 {
  font-size: 1.6rem;
  margin: 0 0 0.6rem;
}
h2 {
  font-size: 1.2rem;
  margin: 0 0 0.6rem;
}
h3 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}
h4 {
  margin: 1rem 0 0.4rem;
}
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: color-mix(in srgb, var(--line) 45%, transparent);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}
code.break {
  word-break: break-all;
}
.loading {
  padding: 3rem;
  text-align: center;
  color: var(--muted);
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.86rem;
}
.empty {
  color: var(--muted);
  padding: 0.6rem 0;
}
[hidden] {
  display: none !important;
}

/* Layout */
.app {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}
.shell-nav {
  position: relative;
}
nav.side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
}
.brand {
  font-size: 1.15rem;
  padding: 0.2rem 0.6rem 1rem;
}
.brand strong {
  color: var(--accent);
}
.brand.big {
  font-size: 1.6rem;
  padding: 0 0 0.6rem;
}
nav.side ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
nav.side a {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
nav.side a:hover {
  background: color-mix(in srgb, var(--line) 50%, transparent);
}
nav.side a.active {
  background: var(--accent);
  color: var(--accent-text);
}
.who {
  margin-top: auto;
  padding: 1rem 0.6rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}
.who-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.4rem;
}
.menu-toggle {
  display: none;
}
main {
  padding: 1.5rem 2rem 4rem;
  min-width: 0;
  max-width: 1400px;
}
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }
  nav.side {
    position: fixed;
    z-index: 40;
    left: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
  }
  body.nav-open nav.side {
    transform: none;
  }
  .menu-toggle {
    display: block;
    position: fixed;
    z-index: 41;
    top: 0.6rem;
    right: 0.6rem;
    font-size: 1.3rem;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
  }
  main {
    padding: 1rem 1rem 4rem;
  }
}

/* Cards and rows */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 0 0 1rem;
}
.card.narrow {
  max-width: 560px;
}
.card.alert {
  border-color: var(--bad);
  background: var(--bad-bg);
}
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.title-row h1,
.title-row h2,
.title-row h3 {
  margin: 0;
}
.toolbar,
.actions,
.row-actions,
.checks,
.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar .field {
  margin: 0;
}
.actions {
  margin-top: 0.8rem;
}
.input-row > input,
.input-row > textarea {
  flex: 1;
  min-width: 0;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 1rem;
}
.grid2.top {
  align-items: start;
  gap: 1rem;
}
@media (max-width: 760px) {
  .grid2,
  .grid3 {
    grid-template-columns: 1fr;
  }
}
.crumbs {
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
}
.link-row {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
  font-size: 0.92rem;
}
.dash {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  align-items: start;
}
.dash .card {
  margin: 0;
}
.count {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 400;
}
ul.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}

/* Forms */
.field {
  display: grid;
  gap: 0.3rem;
  margin: 0 0 0.8rem;
  min-width: 0;
}
.field > label {
  font-weight: 600;
  font-size: 0.9rem;
}
.help {
  color: var(--muted);
  font-size: 0.84rem;
}
input,
select,
textarea,
button {
  font: inherit;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--text);
  min-height: 40px;
}
input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
}
input[type="file"] {
  display: none;
}
input.short {
  max-width: 7rem;
}
textarea {
  resize: vertical;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}
label.check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.3rem 0;
  min-height: 32px;
}
label.check input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-height: 40px;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.primary {
  background: var(--accent);
  color: var(--accent-text);
}
.primary.attention {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}
.secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}
.secondary:hover {
  border-color: var(--muted);
}
button.danger {
  background: var(--bad);
  color: #fff;
}
button.link {
  background: none;
  border: 0;
  color: var(--info);
  padding: 0.2rem 0.3rem;
  min-height: 32px;
  font-weight: 500;
}
button.link.danger {
  color: var(--bad);
  background: none;
}
button.icon {
  background: none;
  border: 0;
  font-size: 1.5rem;
  min-height: 36px;
  padding: 0 0.5rem;
  color: var(--muted);
}
button.tool {
  min-height: 34px;
  min-width: 34px;
  padding: 0.2rem 0.45rem;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 500;
}
button.tool[aria-pressed="true"] {
  background: var(--text);
  color: var(--panel);
}
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--info) 60%, transparent);
  outline-offset: 2px;
}
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--panel);
  margin-bottom: 0.8rem;
}
.segmented button {
  border-radius: 0;
  background: none;
  color: var(--text);
  font-weight: 500;
  border-right: 1px solid var(--line);
}
.segmented button:last-child {
  border-right: 0;
}
.segmented button[aria-pressed="true"] {
  background: var(--text);
  color: var(--panel);
}
.segmented.small button {
  min-height: 32px;
  padding: 0.2rem 0.7rem;
}
.toolbar .segmented {
  margin: 0;
}
.filters {
  display: flex;
  gap: 0.8rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filters .field {
  margin: 0;
  min-width: 170px;
}
.lang-switch {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.8rem;
}
.lang-switch [aria-pressed="true"] {
  font-weight: 700;
  text-decoration: underline;
}

/* Login */
.login-wrap {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}
form.login {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.6rem;
}
form.login .primary {
  width: 100%;
}
.error {
  color: var(--bad);
  font-weight: 600;
  min-height: 1.2em;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.card .table-wrap {
  border: 0;
  margin: 0;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr[tabindex] {
  cursor: pointer;
}
tbody tr[tabindex]:hover {
  background: color-mix(in srgb, var(--line) 30%, transparent);
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
tr.warn td {
  background: var(--bad-bg);
}
dl.detail {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.1rem 0.6rem;
  margin: 0;
  font-size: 0.85rem;
}
dl.detail dt {
  color: var(--muted);
}
dl.detail dd {
  margin: 0;
  word-break: break-word;
}
dl.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.8rem;
  margin: 0.4rem 0;
  font-size: 0.88rem;
}
dl.kv dt {
  color: var(--muted);
}
dl.kv dd {
  margin: 0;
  min-width: 0;
}
dl.answers {
  display: grid;
  grid-template-columns: minmax(140px, 30%) 1fr;
  gap: 0.4rem 1rem;
}
dl.answers dt {
  font-weight: 600;
}
dl.answers dd {
  margin: 0;
  white-space: pre-wrap;
}
@media (max-width: 640px) {
  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
  }
  .table-wrap thead {
    display: none;
  }
  .table-wrap tr {
    border-bottom: 1px solid var(--line);
    padding: 0.4rem 0;
  }
  .table-wrap td {
    border: 0;
    padding: 0.2rem 0.75rem;
  }
  .table-wrap td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
  }
  .num {
    text-align: left;
  }
}

/* Pills */
.pill {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--line) 60%, transparent);
  color: var(--text);
  white-space: nowrap;
  vertical-align: middle;
}
.pill.ok,
.pill.scheduled,
.pill.phase-live {
  background: var(--ok-bg);
  color: var(--ok);
}
.pill.bad {
  background: var(--bad-bg);
  color: var(--bad);
}
.pill.warn,
.pill.test {
  background: var(--warn-bg);
  color: var(--warn);
}
.pill.info,
.pill.phase-vod {
  background: var(--info-bg);
  color: var(--info);
}
.pill.muted,
.pill.archived,
.pill.draft {
  color: var(--muted);
}
.pill.phase-live::before {
  content: "● ";
  color: var(--bad);
}

/* Notices, toasts, dialogs */
.notice {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  margin: 0 0 1rem;
}
.notice.bad {
  background: var(--bad-bg);
  color: var(--bad);
}
.notice.info {
  background: var(--info-bg);
  color: var(--info);
}
#toasts {
  position: fixed;
  z-index: 100;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.5rem;
  max-width: min(420px, calc(100vw - 2rem));
}
.toast {
  padding: 0.7rem 1rem;
  border-radius: 9px;
  background: var(--text);
  color: var(--panel);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}
.toast.error {
  background: var(--bad);
  color: #fff;
}
dialog.dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
dialog.dialog.wide {
  width: min(900px, calc(100vw - 2rem));
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
dialog form {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
}
dialog header,
dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.9rem 1.2rem;
}
dialog header {
  border-bottom: 1px solid var(--line);
}
dialog header h2 {
  margin: 0;
}
dialog footer {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
  flex-wrap: wrap;
}
.dialog-body {
  padding: 1rem 1.2rem;
  overflow: auto;
}
ul.problems li {
  margin-bottom: 0.3rem;
}

/* Event screens */
nav.tabs {
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
  scrollbar-width: thin;
}
nav.tabs a {
  padding: 0.6rem 0.8rem;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  font-weight: 600;
}
nav.tabs a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.route-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}
.route-pair h4 {
  grid-column: 1 / -1;
  margin: 0;
}
@media (max-width: 760px) {
  .route-pair {
    grid-template-columns: 1fr;
  }
}
.route {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.7rem 0.9rem;
}
.route.active {
  border-color: var(--info);
  box-shadow: inset 0 0 0 1px var(--info);
}
.route-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.live-summary {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  min-width: 150px;
  display: grid;
  gap: 0.2rem;
}
.stat span {
  color: var(--muted);
  font-size: 0.82rem;
}
.stat strong {
  font-size: 1.5rem;
}
.phase-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.phase-row select {
  width: auto;
  min-width: 260px;
}
.slot {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.1rem 0.3rem;
  border-radius: 6px;
  margin-bottom: 0.2rem;
}
.slot.on {
  outline: 2px solid var(--info);
}
.slot span {
  min-width: 5.5rem;
  font-size: 0.85rem;
}
.alarm {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bad);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.9rem 1.2rem;
  margin-bottom: 1rem;
  animation: pulse 1.2s ease-in-out infinite alternate;
}
.alarm.soft {
  background: var(--warn-bg);
  color: var(--warn);
  animation: none;
}
.alarm ul {
  margin: 0.4rem 0;
}
@keyframes pulse {
  from {
    box-shadow: 0 0 0 0 rgba(179, 38, 30, 0.6);
  }
  to {
    box-shadow: 0 0 0 10px rgba(179, 38, 30, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .alarm {
    animation: none;
  }
}
.player-wrap {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  max-width: 960px;
  margin: 0.6rem 0;
}
video.player {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}
.gr-status {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}
.chapter-row,
.option-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.4rem;
}
.publish-box {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.publish-box p {
  margin: 0;
}

/* Page editor */
.editor {
  margin-bottom: 0.6rem;
}
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.4rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  position: sticky;
  top: 0;
  z-index: 5;
}
.editor-toolbar select {
  width: auto;
  min-height: 34px;
  padding: 0.2rem 0.4rem;
}
.editor-toolbar.source .tool:not(.wide),
.editor-toolbar.source select[name="block"] {
  opacity: 0.4;
  pointer-events: none;
}
.editor-area,
.editor-source {
  min-height: 320px;
  max-height: 70vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  background: #fff;
  color: #1d1d1f;
  padding: 1rem 1.2rem;
}
.editor-source {
  width: 100%;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--field-bg);
  color: var(--text);
}
.editor-area img {
  cursor: pointer;
}
.page-info {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.88rem;
  margin: 0.4rem 0 0.6rem;
}
.preview-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  transition: max-width 0.2s;
}
.preview-wrap.mobile {
  max-width: 390px;
}
.preview-frame {
  width: 100%;
  height: 720px;
  border: 0;
  display: block;
}
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.8rem;
}
.media-item {
  display: grid;
  gap: 0.3rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.5rem;
  text-align: left;
  color: var(--text);
  font-weight: 400;
  white-space: normal;
  align-content: start;
  min-height: 0;
}
.media-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: color-mix(in srgb, var(--line) 40%, transparent);
  border-radius: 6px;
}
.media-item span {
  font-size: 0.85rem;
  word-break: break-all;
}
label.button input[type="file"] {
  display: none;
}

/* Registration form builder */
ol.field-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
}
ol.field-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
}
ol.field-list li > div:first-child {
  flex: 1;
  min-width: 0;
}
ol.field-list li .row-actions {
  flex: none;
  flex-wrap: nowrap;
}
@media (max-width: 560px) {
  ol.field-list li {
    flex-wrap: wrap;
  }
}
ol.field-list li.inactive {
  opacity: 0.55;
}
details.translation {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  margin-bottom: 0.5rem;
}
details.translation summary {
  cursor: pointer;
  font-weight: 600;
}
.form-preview .watch-scope {
  --accent: var(--accent);
  background: #fff;
  color: #1d1d1f;
  border-radius: var(--radius);
  padding: 1rem;
  border: 1px solid var(--line);
  transition: max-width 0.2s;
}
.form-preview .watch-scope.mobile {
  max-width: 390px;
}
.watch-scope .w-primary {
  margin-top: 1rem;
  background: var(--accent);
  color: #fff;
}
.role-help {
  margin: -0.4rem 0 0.8rem;
  padding-left: 1.1rem;
}
