:root {
  color-scheme: light;
  --page: #f6f7f8;
  --ink: #f7f2e7;
  --ink-strong: #ffffff;
  --muted: #b8b4aa;
  --dark: #0b0d10;
  --dark-2: #12161a;
  --dark-3: #191d21;
  --line: rgba(244, 202, 102, 0.26);
  --line-soft: rgba(255, 255, 255, 0.08);
  --gold: #f6c763;
  --gold-2: #ffe6a2;
  --gold-deep: #ad741b;
  --cyan: #12d8dc;
  --pink: #ff3d78;
  --green: #29d37d;
  --danger: #ff4d66;
  --shadow: 0 18px 38px rgba(10, 12, 14, 0.22);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 247, 248, 0.98)),
    var(--page);
  color: var(--ink);
  font-family:
    "Cairo",
    "Tajawal",
    "Noto Kufi Arabic",
    "Segoe UI",
    Tahoma,
    Arial,
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  width: min(1860px, calc(100% - 56px));
  margin: 0 auto;
  padding: 30px 0 34px;
}

.topbar,
.hero-panel,
.sidebar,
.queue-panel,
.right-rail > section,
.history-panel,
.settings-panel,
.feed-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015)),
    var(--dark);
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 118px;
  display: grid;
  grid-template-columns: 220px minmax(520px, 1fr) minmax(280px, auto);
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  direction: ltr;
  overflow: hidden;
}

.topbar > * {
  direction: rtl;
}

.brand-lockup {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  direction: ltr;
}

.brand-logo-mini {
  width: 160px;
  height: 74px;
  object-fit: contain;
  object-position: center;
}

.brand-tiktok-mini {
  width: 46px;
  height: 46px;
  margin-inline-start: -8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #080a0d;
}

.main-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 1.1vw, 20px);
  min-width: 0;
  overflow: hidden;
}

.nav-item {
  position: relative;
  min-height: 44px;
  max-width: 116px;
  min-width: 0;
  padding: 9px 4px;
  background: transparent;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item::after {
  content: "";
  position: absolute;
  right: 14px;
  left: 14px;
  bottom: 0;
  height: 2px;
  border-radius: 999px;
  background: transparent;
}

.nav-item.active,
.nav-item:hover {
  color: var(--gold-2);
}

.nav-item.active::after {
  background: var(--gold-2);
}

.live-lockup {
  display: grid;
  grid-template-columns: auto auto 86px auto;
  align-items: center;
  gap: 10px;
  direction: ltr;
  min-width: 0;
}

.live-lockup > * {
  direction: rtl;
}

.status-pill,
.live-chip,
.mini-live {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid rgba(255, 61, 120, 0.68);
  border-radius: var(--radius);
  background: rgba(12, 14, 17, 0.84);
  color: var(--ink-strong);
  font-weight: 900;
  white-space: nowrap;
}

.status-pill {
  min-width: 118px;
  min-height: 38px;
  padding: 7px 12px;
  font-size: 13px;
}

.status-pill span,
.live-chip i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--pink);
  box-shadow: 0 0 16px rgba(255, 61, 120, 0.8);
}

.status-pill.connected {
  border-color: rgba(41, 211, 125, 0.7);
}

.status-pill.connected span {
  background: var(--green);
  box-shadow: 0 0 16px rgba(41, 211, 125, 0.8);
}

.status-pill.connecting {
  border-color: rgba(18, 216, 220, 0.7);
}

.status-pill.connecting span {
  background: var(--cyan);
  box-shadow: 0 0 16px rgba(18, 216, 220, 0.8);
}

.status-pill.error,
.status-pill.ended {
  border-color: rgba(255, 77, 102, 0.85);
}

.live-title {
  display: grid;
  gap: 3px;
  min-width: 0;
  max-width: 170px;
}

.live-title span,
.host-name span,
.hero-stats span,
.panel-heading p,
.field span,
.toggle-field span:last-child,
.stage-time span,
.stat-grid span,
.guest-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.live-title strong,
.host-name strong {
  color: var(--ink-strong);
  font-size: 20px;
  line-height: 1.08;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

em {
  color: var(--pink);
  font-style: italic;
}

.host-avatar {
  display: block;
  object-fit: cover;
  border-radius: 999px;
  background: #0e1115;
}

.top-avatar {
  width: 86px;
  height: 86px;
  border: 3px solid var(--gold);
  box-shadow:
    0 0 0 3px rgba(18, 216, 220, 0.18),
    0 12px 30px rgba(0, 0, 0, 0.35);
}

.host-name {
  display: grid;
  gap: 4px;
}

.hero-panel {
  position: relative;
  min-height: 322px;
  margin-top: 22px;
  padding: 24px clamp(22px, 3vw, 46px);
  display: grid;
  grid-template-columns: minmax(330px, 0.95fr) 310px minmax(360px, 1fr);
  align-items: center;
  gap: clamp(18px, 3vw, 42px);
  overflow: hidden;
  background:
    radial-gradient(circle at 17% 102%, rgba(246, 199, 99, 0.26), transparent 34%),
    linear-gradient(125deg, #0a0d10 0%, #0d1115 52%, #10161c 100%);
  direction: ltr;
}

.hero-panel > * {
  direction: rtl;
}

.hero-panel::before,
.hero-panel::after {
  content: "";
  position: absolute;
  inset-inline: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(246, 199, 99, 0.84), transparent);
  pointer-events: none;
}

.hero-panel::before {
  top: 12px;
}

.hero-panel::after {
  bottom: 12px;
}

.hero-logo-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-logo {
  width: min(118%, 660px);
  max-height: 304px;
  object-fit: contain;
  filter: drop-shadow(0 20px 28px rgba(0, 0, 0, 0.46));
  transform: scale(1.08);
  transform-origin: center;
}

.hero-photo-wrap {
  justify-self: center;
  position: relative;
  width: 246px;
  height: 246px;
  border-radius: 999px;
  padding: 7px;
  background: conic-gradient(from 0deg, var(--cyan), var(--gold), var(--pink), var(--cyan));
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.42);
}

.hero-avatar {
  width: 100%;
  height: 100%;
  border: 6px solid #090b0e;
}

.hero-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: 12px;
}

.live-chip {
  min-height: 36px;
  padding: 7px 15px;
  font-size: 16px;
}

.hero-copy h1 {
  color: var(--ink-strong);
  font-size: clamp(34px, 4.1vw, 66px);
  line-height: 1.05;
  font-weight: 900;
}

.hero-copy > p {
  direction: ltr;
  color: var(--ink-strong);
  font-size: clamp(30px, 3.8vw, 58px);
  line-height: 0.96;
  font-weight: 900;
  text-align: left;
}

.status-text {
  min-height: 32px;
  color: var(--gold-2);
  font-size: 16px;
  font-weight: 900;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(128px, 1fr));
  gap: 10px;
  width: 100%;
}

.hero-stats article,
.stat-grid article {
  min-height: 68px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  padding: 12px 14px;
  display: grid;
  align-content: center;
  gap: 5px;
}

.hero-stats strong,
.stat-grid strong {
  color: var(--ink-strong);
  font-size: 20px;
  line-height: 1;
  font-weight: 900;
}

#liveHandle {
  direction: ltr;
  text-align: right;
  font-size: 17px;
}

.dashboard-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 250px minmax(640px, 1fr) 430px;
  grid-template-areas:
    "side queue right"
    "side winners right"
    "side participants right"
    "side settings right"
    "side comments activity";
  gap: 18px;
  align-items: start;
  direction: ltr;
}

.dashboard-grid > * {
  direction: rtl;
}

.sidebar {
  grid-area: side;
  min-height: 492px;
  padding: 20px 16px;
  display: grid;
  align-content: start;
  gap: 10px;
  position: sticky;
  top: 16px;
}

.sidebar h2 {
  margin: 4px 4px 14px;
  color: var(--ink-strong);
  font-size: 20px;
  font-weight: 900;
}

.side-link {
  width: 100%;
  min-height: 58px;
  justify-content: flex-start;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-link span {
  flex: 0 0 28px;
  width: 28px;
  color: var(--gold-2);
  text-align: center;
  font-size: 22px;
  line-height: 1;
}

.side-link.active,
.side-link:hover {
  border-color: var(--line);
  background: linear-gradient(90deg, rgba(246, 199, 99, 0.18), rgba(246, 199, 99, 0.06));
  color: var(--gold-2);
}

.queue-panel {
  grid-area: queue;
  min-height: 492px;
  overflow: hidden;
}

.right-rail {
  grid-area: right;
  display: grid;
  gap: 18px;
}

.settings-panel {
  grid-area: settings;
  padding-bottom: 18px;
}

.history-panel {
  min-height: 292px;
  overflow: hidden;
}

.winners-panel {
  grid-area: winners;
}

.participants-panel {
  grid-area: participants;
}

.feed-panel {
  min-height: 320px;
}

#commentsPanel {
  grid-area: comments;
}

#activityPanel {
  grid-area: activity;
}

.panel-heading {
  min-height: 86px;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-heading.compact {
  min-height: 72px;
}

.panel-heading h2 {
  color: var(--ink-strong);
  font-size: 22px;
  line-height: 1.15;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.panel-heading,
.panel-heading > div,
.section-heading,
.side-header,
.stats-card,
.current-card,
.history-panel,
.settings-panel,
.feed-panel {
  min-width: 0;
}

.panel-heading p,
.field span,
.toggle-field span:last-child,
.stat-grid span,
.history-copy p,
.history-copy small {
  overflow-wrap: anywhere;
}

.count-badge {
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(246, 199, 99, 0.1);
  color: var(--gold-2);
}

.count-badge strong {
  font-size: 24px;
  line-height: 1;
}

.panel-actions,
.settings-actions,
.stage-actions,
.control-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.gold-button,
.outline-button,
.export-link {
  min-height: 42px;
  border-radius: var(--radius);
  text-decoration: none;
}

.gold-button {
  border: 1px solid rgba(255, 230, 162, 0.45);
  background: linear-gradient(180deg, #ffe7a8 0%, #f2bc56 58%, #b77a1f 100%);
  color: #17120a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.outline-button,
.export-link {
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink);
}

.outline-button:hover,
.export-link:hover {
  border-color: var(--line);
  color: var(--gold-2);
}

.outline-button.danger {
  border-color: rgba(255, 77, 102, 0.34);
  color: #ffc6cf;
}

.export-link {
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.history-panel .export-link {
  min-width: 128px;
}

.queue-table-wrap {
  width: 100%;
  overflow: auto;
}

.queue-table {
  width: 100%;
  min-width: 870px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #1a1b1d;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

td {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

tbody tr:not(.empty-row) {
  background: rgba(255, 255, 255, 0.018);
}

tbody tr:not(.empty-row):nth-child(even) {
  background: rgba(255, 255, 255, 0.035);
}

tbody tr:not(.empty-row):hover {
  background: rgba(246, 199, 99, 0.07);
}

th:nth-child(1),
td:nth-child(1) {
  width: 78px;
  text-align: center;
}

th:nth-child(2),
td:nth-child(2) {
  width: 290px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 178px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 150px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 238px;
}

.empty-row td {
  height: 245px;
  color: var(--muted);
  text-align: center;
  font-size: 18px;
}

.rank {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(246, 199, 99, 0.36);
  border-radius: var(--radius);
  color: var(--gold-2);
  background: rgba(246, 199, 99, 0.1);
  font-size: 17px;
  font-weight: 900;
}

.rank.ready {
  color: #18120a;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
}

.competitor-cell {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.avatar-token,
.guest-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background:
    linear-gradient(145deg, rgba(18, 216, 220, 0.24), rgba(255, 61, 120, 0.2)),
    #1b2025;
  color: var(--ink-strong);
  font-weight: 900;
}

.avatar-token {
  width: 46px;
  height: 46px;
  border: 2px solid var(--gold);
  font-size: 14px;
}

.user-lines {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.user-lines strong,
.guest-copy strong,
.comment-list strong,
.activity-list strong {
  color: var(--ink-strong);
  font-size: 15px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.user-lines span,
.comment-list span,
.activity-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.user-lines span {
  direction: ltr;
  text-align: right;
}

.request-line {
  margin-top: 4px;
  color: #d7d1c4;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.status-tag {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid rgba(246, 199, 99, 0.22);
  border-radius: var(--radius);
  background: rgba(246, 199, 99, 0.08);
  color: var(--gold-2);
  font-size: 13px;
  font-weight: 900;
}

.status-tag.ready {
  border-color: rgba(41, 211, 125, 0.38);
  background: rgba(41, 211, 125, 0.1);
  color: #76ecad;
}

.status-tag i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
}

.row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 42px;
  gap: 8px;
}

.row-actions button {
  min-height: 38px;
  padding: 8px 10px;
}

.kebab-button {
  min-width: 42px;
  padding-inline: 0;
}

.current-card {
  min-height: 260px;
  overflow: hidden;
}

.mini-live {
  min-height: 34px;
  padding: 7px 12px;
  color: #ff9eb8;
  font-size: 12px;
}

.stage-guest {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 20px 20px 10px;
}

.stage-guests-list {
  padding: 16px 18px 8px;
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.stage-empty,
.stage-guest-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.stage-empty {
  min-height: 108px;
  padding: 18px;
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
}

.stage-empty strong {
  color: var(--ink-strong);
  font-size: 16px;
  font-weight: 900;
}

.stage-empty span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stage-guest-card {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.stage-guest-main {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.guest-avatar {
  width: 72px;
  height: 72px;
  border: 3px solid var(--gold);
  font-size: 22px;
}

.stage-guest-card .guest-avatar {
  width: 54px;
  height: 54px;
  border-width: 2px;
  font-size: 17px;
}

.guest-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.guest-copy strong {
  font-size: 20px;
}

.guest-copy span {
  direction: ltr;
  text-align: right;
}

.guest-copy p {
  margin: 0;
  color: #d7d1c4;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.stage-elapsed {
  min-width: 62px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(18, 216, 220, 0.24);
  border-radius: var(--radius);
  background: rgba(18, 216, 220, 0.08);
  color: #9af7f9;
  font-size: 14px;
  font-weight: 900;
  direction: ltr;
}

.stage-guest-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stage-guest-actions button {
  min-height: 36px;
  padding: 8px 9px;
  font-size: 12px;
}

.vip-button,
.result-badge.vip {
  border-color: rgba(255, 61, 120, 0.38);
  background: rgba(255, 61, 120, 0.1);
  color: #ffc1d1;
}

.wave-bars {
  height: 44px;
  margin: 6px 20px 12px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  align-items: end;
  padding: 0 4px;
  overflow: hidden;
}

.wave-bars span {
  min-height: 8px;
  border-radius: 999px 999px 0 0;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(18, 216, 220, 0.35);
}

.wave-bars span:nth-child(2n) {
  height: 24px;
}

.wave-bars span:nth-child(3n) {
  height: 36px;
}

.wave-bars span:nth-child(4n) {
  height: 16px;
  background: var(--pink);
}

.stage-time {
  margin: 0 20px;
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.stage-time strong {
  color: var(--ink-strong);
  font-size: 32px;
  line-height: 1;
  font-weight: 900;
}

.stage-comment {
  min-height: 48px;
  margin: 12px 20px 0;
  color: #d7d1c4;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.stage-manual-form {
  margin: 12px 20px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.stage-manual-form button {
  min-height: 46px;
}

.stage-actions {
  padding: 16px 20px 20px;
}

.stage-actions button {
  flex: 1;
}

.stats-card {
  padding-bottom: 16px;
}

.stats-card h2 {
  padding: 18px 20px 12px;
  color: var(--gold-2);
  font-size: 20px;
  font-weight: 900;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px;
}

.stat-grid article {
  min-height: 72px;
}

.stat-grid strong {
  font-size: 24px;
}

.connect-form {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(220px, 1fr) 150px auto;
  gap: 12px;
  align-items: end;
  padding: 18px 20px 0;
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

input[type="text"],
input[type="url"],
input[type="date"],
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink-strong);
  padding: 10px 13px;
  outline: none;
  font-size: 14px;
  font-weight: 800;
}

input[type="text"]::placeholder,
input[type="url"]::placeholder {
  color: rgba(247, 242, 231, 0.42);
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="date"]:focus,
select:focus {
  border-color: rgba(18, 216, 220, 0.66);
  box-shadow: 0 0 0 3px rgba(18, 216, 220, 0.11);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--gold-2) 50%),
    linear-gradient(135deg, var(--gold-2) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 20px,
    calc(100% - 12px) 20px;
  background-size:
    6px 6px,
    6px 6px;
  background-repeat: no-repeat;
  padding-inline-end: 34px;
}

#liveUrl {
  direction: ltr;
  text-align: left;
}

.toggle-field {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 11px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
  white-space: nowrap;
}

.toggle-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 160ms ease;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
  transition: transform 160ms ease;
}

.toggle-field input:checked + .toggle-track {
  background: var(--cyan);
}

.toggle-field input:checked + .toggle-track::after {
  transform: translateX(-18px);
}

.manual-form {
  margin: 14px 20px 0;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 12px;
  padding: 16px 20px 0;
}

.compact-field {
  gap: 6px;
}

.compact-field input,
.compact-field select {
  min-height: 42px;
}

.history-form {
  margin: 14px 20px 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.history-note-field {
  grid-column: span 2;
}

.history-form-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.history-form-actions button {
  min-height: 42px;
}

.comment-list,
.activity-list,
.history-list,
.tracked-comments-list {
  margin: 0;
  padding: 16px 20px 20px;
  list-style: none;
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.comment-list li,
.activity-list li,
.history-list li,
.tracked-comments-list li {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.032);
  padding: 11px 13px;
  display: grid;
  gap: 6px;
}

.tracked-users-form {
  margin: 16px 20px 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.tracked-users-form input,
.tracked-users-form textarea {
  width: 100%;
  min-height: 46px;
  resize: vertical;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(5, 7, 10, 0.7);
  color: var(--ink-strong);
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
}

.tracked-users-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px 0;
}

.tracked-users-badges span {
  border: 1px solid rgba(246, 199, 99, 0.36);
  border-radius: 999px;
  background: rgba(246, 199, 99, 0.1);
  color: var(--gold-2);
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 900;
}

.tracked-users-badges .tracked-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-left: 7px;
}

.tracked-user-badge button {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-strong);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: inline-grid;
  place-items: center;
}

.tracked-users-badges .muted-badge {
  border-color: var(--line-soft);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.tracked-comments-list {
  max-height: 520px;
}

.tracked-comment-item {
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: start;
}

.tracked-avatar {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 2px solid var(--gold);
  object-fit: cover;
  background: #11151a;
  color: var(--gold-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.tracked-comment-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.tracked-comment-copy strong {
  color: var(--ink-strong);
  font-size: 15px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.tracked-comment-copy strong span {
  color: var(--muted);
  direction: ltr;
  unicode-bidi: isolate;
  font-size: 12px;
}

.tracked-comment-copy p {
  margin: 0;
  color: #ded7ca;
  font-size: 13px;
  line-height: 1.65;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.tracked-comment-copy small {
  color: var(--muted);
  direction: ltr;
  text-align: right;
  font-weight: 800;
}

.history-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: 430px;
}

.history-list .empty-history {
  grid-column: 1 / -1;
  min-height: 140px;
  align-content: center;
  justify-items: center;
}

.history-item {
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.history-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.history-copy strong {
  color: var(--ink-strong);
  font-size: 15px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.history-copy span,
.history-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-copy span {
  direction: ltr;
  text-align: right;
}

.history-copy p {
  color: #ded7ca;
  font-size: 12px;
  line-height: 1.55;
  font-weight: 800;
}

.history-item-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

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

.history-row-actions button {
  min-height: 30px;
  padding: 6px 9px;
  font-size: 11px;
}

.result-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  padding: 7px 10px;
  border: 1px solid rgba(246, 199, 99, 0.36);
  background: rgba(246, 199, 99, 0.1);
  color: var(--gold-2);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.result-badge.participant {
  border-color: rgba(18, 216, 220, 0.28);
  background: rgba(18, 216, 220, 0.08);
  color: #9af7f9;
}

.comment-list p {
  margin: 0;
  color: #ded7ca;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.activity-list .match,
.activity-list .stage {
  border-color: rgba(246, 199, 99, 0.26);
  background: rgba(246, 199, 99, 0.07);
}

.activity-list .error {
  border-color: rgba(255, 77, 102, 0.3);
  background: rgba(255, 77, 102, 0.08);
}

.activity-list .duplicate {
  border-color: rgba(255, 61, 120, 0.28);
}

.muted {
  color: var(--muted);
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 22px;
  bottom: 22px;
  min-width: 230px;
  max-width: min(440px, calc(100vw - 44px));
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b0d10;
  color: var(--ink-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.app-footer {
  min-height: 72px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015)),
    var(--dark);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  color: var(--ink);
}

.app-footer span {
  color: var(--gold-2);
  font-size: 15px;
  font-weight: 900;
}

.app-footer strong {
  direction: ltr;
  color: var(--ink-strong);
  font-size: 19px;
  font-weight: 900;
}

@media (max-width: 1500px) {
  .topbar {
    grid-template-columns: 190px 1fr;
  }

  .live-lockup {
    grid-column: 1 / -1;
    justify-content: end;
  }

  .dashboard-grid {
    grid-template-columns: 220px minmax(580px, 1fr) 390px;
  }
}

@media (max-width: 1240px) {
  .app-shell {
    width: min(100% - 28px, 1860px);
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .main-nav {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    flex: 0 0 auto;
    max-width: none;
  }

  .hero-panel {
    grid-template-columns: 1fr 230px;
  }

  .hero-copy {
    grid-column: 1 / -1;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "side"
      "queue"
      "right"
      "winners"
      "participants"
      "settings"
      "comments"
      "activity";
  }

  .sidebar {
    position: static;
    min-height: auto;
    display: flex;
    align-items: center;
    overflow-x: auto;
  }

  .sidebar h2 {
    margin: 0 0 0 10px;
    white-space: nowrap;
  }

  .side-link {
    width: auto;
    min-width: 132px;
    max-width: 180px;
  }

  .right-rail {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.86fr);
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 18px, 1860px);
    padding: 10px 0 22px;
  }

  .topbar {
    gap: 10px;
    padding: 12px;
  }

  .brand-lockup {
    justify-content: center;
  }

  .brand-logo-mini {
    width: 132px;
  }

  .brand-tiktok-mini {
    width: 42px;
    height: 42px;
  }

  .main-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    overflow: visible;
    width: 100%;
    padding-bottom: 0;
  }

  .nav-item {
    width: 100%;
    max-width: none;
    min-height: 38px;
    padding: 7px 6px;
    font-size: 13px;
    line-height: 1.25;
    white-space: normal;
  }

  .nav-item::after {
    right: 22%;
    left: 22%;
  }

  .live-lockup {
    width: 100%;
    grid-template-columns: 1fr auto;
    justify-content: stretch;
  }

  .status-pill {
    width: 100%;
    min-width: 0;
  }

  .live-title,
  .host-name {
    display: none;
  }

  .top-avatar {
    width: 62px;
    height: 62px;
  }

  .hero-panel {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 18px 14px 24px;
  }

  .hero-photo-wrap {
    width: 190px;
    height: 190px;
  }

  .hero-copy {
    justify-items: center;
  }

  .hero-copy > p {
    text-align: center;
  }

  .hero-stats,
  .stat-grid,
  .right-rail,
  .history-list {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-actions,
  .settings-actions,
  .stage-actions,
  .control-actions {
    width: 100%;
  }

  .panel-actions > *,
  .settings-actions > *,
  .stage-actions > *,
  .control-actions > * {
    flex: 1;
  }

  .connect-form,
  .manual-form,
  .stage-manual-form,
  .filter-bar,
  .history-form,
  .tracked-users-form {
    grid-template-columns: 1fr;
  }

  .history-note-field {
    grid-column: auto;
  }

  .history-form-actions {
    justify-content: stretch;
  }

  .history-form-actions button {
    flex: 1;
  }

  .history-item {
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: start;
  }

  .history-item-side {
    grid-column: 1 / -1;
    width: 100%;
    justify-items: stretch;
  }

  .history-row-actions button,
  .history-item-side .result-badge {
    flex: 1;
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
    overflow: visible;
    padding: 12px;
  }

  .sidebar h2 {
    grid-column: 1 / -1;
    margin: 0 0 4px;
    text-align: center;
  }

  .side-link {
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 50px;
    padding: 8px 7px;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
  }

  .side-link span {
    flex: 0 0 auto;
    width: auto;
    font-size: 18px;
  }

  .stats-card h2 {
    padding-inline: 16px;
    font-size: 18px;
  }

  .stat-grid {
    padding: 0 12px 16px;
  }
}

body[data-view="homePanel"] #winnersPanel,
body[data-view="homePanel"] #participantsPanel,
body[data-view="homePanel"] #settingsPanel,
body[data-view="homePanel"] #commentsPanel,
body[data-view="homePanel"] #trackedPanel,
body[data-view="homePanel"] #activityPanel {
  display: none;
}

body:not([data-view="homePanel"]) .hero-panel {
  display: none;
}

body:not([data-view="homePanel"]) .dashboard-grid {
  grid-template-columns: 250px minmax(0, 1fr);
  grid-template-areas: "side page";
}

body:not([data-view="homePanel"]) .queue-panel,
body:not([data-view="homePanel"]) .history-panel,
body:not([data-view="homePanel"]) .settings-panel,
body:not([data-view="homePanel"]) .feed-panel,
body:not([data-view="homePanel"]) .right-rail {
  display: none;
}

body[data-view="queuePanel"] #queuePanel,
body[data-view="winnersPanel"] #winnersPanel,
body[data-view="participantsPanel"] #participantsPanel,
body[data-view="settingsPanel"] #settingsPanel,
body[data-view="commentsPanel"] #commentsPanel,
body[data-view="trackedPanel"] #trackedPanel,
body[data-view="activityPanel"] #activityPanel {
  display: block;
  grid-area: page;
}

body[data-view="statsPanel"] .right-rail {
  display: block;
  grid-area: page;
}

body[data-view="statsPanel"] .right-rail .current-card {
  display: none;
}

body[data-view="statsPanel"] #statsPanel {
  display: block;
}

body:not([data-view="homePanel"]) .sidebar {
  min-height: 560px;
}

body:not([data-view="homePanel"]) .queue-panel,
body:not([data-view="homePanel"]) .history-panel,
body:not([data-view="homePanel"]) .settings-panel,
body:not([data-view="homePanel"]) .feed-panel,
body:not([data-view="homePanel"]) #statsPanel {
  min-height: min(680px, calc(100vh - 238px));
}

@media (max-width: 1240px) {
  body:not([data-view="homePanel"]) .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "side"
      "page";
  }

  body:not([data-view="homePanel"]) .sidebar {
    min-height: auto;
  }
}

@media (max-width: 860px) {
  body:not([data-view="homePanel"]) .queue-panel,
  body:not([data-view="homePanel"]) .history-panel,
  body:not([data-view="homePanel"]) .settings-panel,
  body:not([data-view="homePanel"]) .feed-panel,
  body:not([data-view="homePanel"]) #statsPanel {
    min-height: auto;
  }

  .app-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
