* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-main: #050505;
  --card: rgba(18, 18, 18, 0.95);
  --gold: #caa24a;
  --gold-soft: #e3c97a;
  --text: #f5f1e6;
  --muted: #d7c9a2;
  --border: rgba(202, 162, 74, 0.25);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 22px;
  color-scheme: dark;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: Georgia, "Times New Roman", "Traditional Arabic", "Sakkal Majalla", serif;
  background: linear-gradient(135deg, #000000, #111111, #050505);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.page-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top center, rgba(202, 162, 74, 0.08), transparent 30%),
    radial-gradient(circle at bottom right, rgba(23, 61, 151, 0.08), transparent 30%);
  pointer-events: none;
}

.topbar,
.channel-band,
.container,
.footer,
.admin-shell {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 32px));
  margin-right: auto;
  margin-left: auto;
}

.topbar,
.channel-band,
.player-card,
.info-card,
.footer,
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  margin-top: 24px;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand-logo,
.logo-fallback {
  width: 110px;
  height: 110px;
  flex: 0 0 110px;
  object-fit: contain;
  border-radius: 50%;
  background: #000;
  border: 2px solid rgba(202, 162, 74, 0.35);
  padding: 6px;
}

.logo-fallback {
  display: grid;
  place-items: center;
  color: var(--gold-soft);
  font-size: 1.6rem;
  letter-spacing: 0.04em;
}

.brand-text h1 {
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  color: var(--gold-soft);
  margin-bottom: 8px;
  line-height: 1.3;
  font-weight: normal;
}

.brand-text h2,
.lede {
  font-size: 1.2rem;
  color: var(--text);
  font-weight: normal;
  margin-bottom: 8px;
}

.kicker,
.kicker-ar,
.brand-text p,
.title-block p,
.hint,
.empty,
.footer {
  color: var(--muted);
}

.kicker,
.kicker-ar {
  margin-bottom: 4px;
}

.channel-band {
  margin-top: 24px;
  padding: 22px;
}

.channel-rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

button.channel-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: auto;
  margin: 0;
  padding: 12px 10px 14px;
  background: #0d0d0d;
  color: inherit;
  font-family: inherit;
  font-weight: normal;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: none;
}

button.channel-tile:hover {
  transform: none;
  opacity: 1;
  border-color: var(--gold-soft);
}

button.channel-tile.is-active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(202, 162, 74, 0.45);
}

.channel-no {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: var(--gold);
}

.channel-logo,
.tile-fallback {
  width: 72px;
  height: 72px;
  flex-basis: 72px;
  margin: 8px auto;
  padding: 4px;
  font-size: 1rem;
}

.channel-name {
  color: var(--gold-soft);
  line-height: 1.35;
}

.channel-ar {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.container {
  margin-top: 24px;
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 24px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.player-card,
.info-card {
  padding: 24px;
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.title-block h3,
.info-card h3,
.admin-card h2,
.auth-card h1,
.admin-bar h1 {
  color: var(--gold-soft);
  font-weight: normal;
}

.title-block h3,
.admin-card h2 {
  font-size: 1.4rem;
  margin-bottom: 6px;
}

.title-block p,
.info-card p {
  color: var(--muted);
  line-height: 1.6;
}

.info-card p + p {
  margin-top: 10px;
}

.live-badge,
.pill {
  background: rgba(202, 162, 74, 0.12);
  color: var(--gold-soft);
  border: 1px solid rgba(202, 162, 74, 0.35);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 0.04em;
}

.pill.off {
  color: #ffb4b4;
  border-color: rgba(255, 155, 155, 0.35);
  background: rgba(120, 20, 20, 0.25);
}

.video-wrapper {
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  border: 1px solid rgba(202, 162, 74, 0.18);
}

.video-player {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
  background: #000;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, var(--gold), #8b6824);
}

button:hover,
.btn:hover {
  transform: translateY(-1px);
  opacity: 0.96;
}

button.ghost,
a.btn.ghost {
  background: transparent;
  color: var(--gold-soft);
  border: 1px solid var(--border);
}

button.danger {
  background: #3a2424;
  color: #ffd0d0;
}

.status-box {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #0d0d0d;
  border: 1px solid var(--border);
  color: var(--muted);
}

.logo-box {
  text-align: center;
  margin-bottom: 20px;
}

.side-logo,
.side-fallback {
  width: 180px;
  height: 180px;
  max-width: 100%;
  margin: 0 auto;
  flex-basis: auto;
  font-size: 2.2rem;
}

.info-card ul {
  list-style: none;
  margin-bottom: 8px;
}

.info-card li {
  padding: 10px 0;
  border-bottom: 1px solid rgba(202, 162, 74, 0.12);
}

.footer {
  margin-bottom: 24px;
  text-align: center;
  padding: 18px;
}

.footer p:first-child {
  margin-bottom: 6px;
}

.footer-meta {
  margin-top: 10px;
  font-size: 0.8rem;
}

.footer-meta a {
  color: rgba(215, 201, 162, 0.55);
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  position: relative;
  z-index: 1;
}

.auth-card,
.admin-card,
.admin-bar {
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
}

.auth-card h1,
.admin-bar h1 {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.admin-shell {
  padding: 24px 0 40px;
}

.admin-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.admin-links {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-links form,
.row-actions form {
  margin: 0;
}

.admin-card {
  margin-top: 18px;
}

.admin-page label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
}

.admin-page label.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.admin-page input[type="text"],
.admin-page input[type="url"],
.admin-page input[type="password"],
.admin-page input[type="file"],
.admin-page textarea,
.admin-page select {
  width: 100%;
  padding: 12px 14px;
  background: #0d0d0d;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  font: inherit;
}

.admin-page textarea {
  min-height: 90px;
  resize: vertical;
}

.admin-page input[type="checkbox"] {
  width: auto;
  accent-color: #caa24a;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

.hint {
  margin-top: 8px;
  line-height: 1.5;
}

.admin-card button,
.auth-card button {
  margin-top: 18px;
}

.banner {
  position: relative;
  z-index: 1;
  margin: 0 auto 16px;
  width: min(1200px, calc(100% - 32px));
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.auth-card .banner,
.admin-shell .banner {
  width: auto;
  margin: 0 0 16px;
}

.banner.ok {
  color: var(--gold-soft);
  background: rgba(202, 162, 74, 0.08);
}

.banner.bad {
  color: #ffb4b4;
  background: rgba(120, 20, 20, 0.25);
  border-color: rgba(255, 155, 155, 0.35);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}

.section-head .btn {
  margin-top: 0;
  flex: 0 0 auto;
}

.channel-row {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(202, 162, 74, 0.12);
}

a.channel-open {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  background: transparent;
  font-weight: normal;
  border: 1px solid transparent;
}

a.channel-open:hover,
.channel-row.is-selected a.channel-open {
  transform: none;
  opacity: 1;
  border-color: var(--gold);
  background: rgba(202, 162, 74, 0.06);
}

.row-logo,
.row-fallback {
  width: 64px;
  height: 64px;
  flex-basis: 64px;
  padding: 4px;
  font-size: 0.95rem;
}

.row-copy {
  min-width: 0;
}

.row-copy strong,
.row-copy span {
  display: block;
}

.admin-page .lede[dir="rtl"],
.admin-card > .hint[dir="rtl"],
.row-copy [dir="rtl"] {
  text-align: left;
}

.stream-url {
  color: var(--muted);
  direction: ltr;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.row-actions button,
.row-actions .btn {
  margin: 0;
  padding: 8px 12px;
  min-height: 40px;
}

.edit-logo {
  width: 84px;
  height: 84px;
  object-fit: contain;
  margin-top: 10px;
  border-radius: 50%;
  background: #000;
  border: 1px solid var(--border);
}

a {
  color: var(--gold-soft);
}

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

@media (max-width: 900px) {
  .container,
  .form-grid,
  .admin-bar,
  .section-head {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .brand,
  .player-header,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .brand {
    align-items: center;
    text-align: center;
  }

  .brand-text h2,
  .kicker-ar {
    text-align: center;
  }

  .channel-rail {
    display: flex;
    overflow-x: auto;
    padding-bottom: 6px;
  }

  button.channel-tile {
    flex: 0 0 148px;
  }

  .actions button,
  .auth-card button,
  .admin-card form > button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  button:hover,
  .btn:hover {
    transform: none;
  }

  .status-icon .i-wait {
    animation: none;
  }
}

.public-page .topbar,
.public-page .channel-band,
.public-page .info-card,
.public-page .container,
.public-page .footer {
  width: min(520px, calc(100% - 20px));
}

.public-page .topbar {
  margin-top: 12px;
  padding: 8px 8px 0;
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
}

.public-page .lang-switch {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.public-page .lang-switch button {
  min-height: 40px;
  padding: 8px 16px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.public-page .lang-switch button[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--gold), #8b6824);
  color: #fff;
  border-color: transparent;
}

.public-page h1 {
  color: var(--gold-soft);
  font-size: 1.45rem;
  font-weight: normal;
  line-height: 1.45;
}

.public-page .channel-band {
  margin-top: 14px;
  padding: 14px 10px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.public-page .channel-rail {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 14px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.public-page button.channel-tile {
  flex: 0 0 108px;
  width: 108px;
  padding: 8px 6px 10px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.public-page button.channel-tile.is-active {
  border-color: var(--gold);
  background: rgba(202, 162, 74, 0.08);
}

.public-page button.channel-tile.is-main {
  position: sticky;
  inset-inline-start: 0;
  z-index: 2;
  background: #0b0b0b;
}

.public-page .channel-logo,
.public-page .tile-fallback {
  width: 76px;
  height: 76px;
  margin: 6px auto;
}

.public-page .channel-label {
  display: block;
  color: var(--gold-soft);
  font-size: 0.92rem;
  line-height: 1.35;
}

.public-page .info-card {
  margin: 8px auto 0;
  padding: 4px 12px 8px;
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
}

.public-page .info-card h2 {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: normal;
  margin-bottom: 6px;
}

.public-page .info-card p {
  color: var(--muted);
  line-height: 1.6;
}

.public-page .info-card p + p {
  margin-top: 6px;
}

.public-page .container {
  display: block;
  margin-top: 8px;
  margin-bottom: 8px;
}

.public-page .player-card {
  padding: 10px;
}

.public-page .icon-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
}

.public-page button.icon-btn,
.public-page .live-mark {
  min-height: 52px;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #0d0d0d;
  color: var(--gold-soft);
  border: 1px solid var(--border);
}

.public-page button.icon-btn {
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 50%;
}

.public-page .live-mark {
  width: auto;
  height: auto;
  padding: 8px 14px;
  border-radius: 999px;
  color: #ff4d4d;
  border-color: rgba(255, 77, 77, 0.45);
  font-size: 0.78rem;
  font-weight: bold;
  letter-spacing: 0.08em;
}

.public-page .live-mark.is-on {
  background: #e10600;
  color: #fff;
  border-color: #e10600;
}

.public-page .live-mark.is-broken {
  background: transparent;
  color: #ff2a2a;
  border-color: #ff2a2a;
}

.public-page .live-mark svg {
  width: 18px;
  height: 18px;
}

.public-page button.icon-btn:hover {
  transform: none;
}

.public-page button.icon-btn svg,
.public-page .status-icon svg {
  width: 24px;
  height: 24px;
}

.public-page .status-icon .i-wait {
  animation: spin 0.9s linear infinite;
  transform-origin: center;
}

.public-page .footer {
  margin: 4px auto 16px;
  padding: 8px;
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 0.85rem;
}

.public-page .footer a {
  color: var(--muted);
  text-decoration: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
