:root {
  --bg: #0b0f17;
  --card: #121a27;
  --card-2: #172233;
  --line: #24334a;
  --text: #e9eff9;
  --muted: #8ea2bc;
  --accent: #4f8cff;
  --accent-2: #28c7a7;
  --danger: #ff6b6b;
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  padding: 20px;
  color: var(--text);
  font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  background:
    radial-gradient(900px 520px at 100% -10%, rgba(79, 140, 255, 0.17), transparent 60%),
    radial-gradient(800px 480px at 0% 0%, rgba(40, 199, 167, 0.11), transparent 55%),
    var(--bg);
}

.shell {
  width: min(980px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(79, 140, 255, 0.35);
}

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

h1 {
  font-size: 20px;
  line-height: 1.3;
}

h2 {
  font-size: 16px;
  line-height: 1.4;
}

h3 {
  font-size: 15px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

.auth {
  padding: 14px 16px;
}

.auth-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.addon-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.token-row {
  display: flex;
  gap: 8px;
}

.token-row input {
  flex: 1;
}

#authMsg {
  min-height: 20px;
  margin-top: 6px;
}

#authMsg:empty {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-size: 13px;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  background: #0d1420;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder {
  color: #5c6d84;
}

input:focus,
select:focus {
  border-color: rgba(79, 140, 255, 0.8);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.16);
}

button,
a.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: #223049;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.12s, filter 0.15s, opacity 0.15s;
  white-space: nowrap;
}

button:hover,
a.ghost:hover {
  filter: brightness(1.15);
}

button:active,
a.ghost:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

.primary {
  background: linear-gradient(135deg, var(--accent), #6aa4ff);
}

.warn {
  background: #7a5a12;
}

.danger {
  background: #6c2229;
}

.ghost {
  background: #1a2536;
  border: 1px solid var(--line);
}

.small {
  padding: 7px 11px;
  font-size: 12.5px;
  border-radius: 9px;
}

form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.span-2 {
  grid-column: 1 / -1;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.quals {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.quals legend {
  padding: 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.quals label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.quals input {
  width: auto;
  accent-color: var(--accent);
}

.tg {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.tg legend {
  padding: 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.tg-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.tg-toggle input {
  width: auto;
  accent-color: var(--accent);
}

.tg .grid-2 {
  margin-top: 10px;
}

.tg-hint {
  margin-top: 8px;
}

.tg-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

details {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.section-head,
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.list-head {
  margin: 22px 2px 12px;
}

.streams {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 14px;
}

.stream {
  min-width: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s;
}

.stream.is-running {
  border-color: rgba(52, 211, 153, 0.35);
}

.stream-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stream-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.stream-title h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.13);
  animation: pulse 2s infinite;
}

.dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.13);
}

.dot.off {
  background: #55667d;
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 7px rgba(52, 211, 153, 0.04);
  }
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #16202f;
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.pill.ok {
  color: var(--ok);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.08);
}

.pill.bad {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
}

.pill.warn {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.error {
  padding: 8px 10px;
  border: 1px solid rgba(255, 107, 107, 0.28);
  border-radius: 10px;
  background: rgba(255, 107, 107, 0.07);
  color: #ffb1b1;
  font-size: 12.5px;
  word-break: break-word;
}

.link-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.tag {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 6px;
  background: #1d2a3e;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.link-row code {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #1c293c;
  border-radius: 8px;
  background: #0c1320;
  color: #8ab4ff;
  font-size: 11.5px;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  direction: ltr;
  text-align: left;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.empty {
  padding: 34px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 4px 6px;
}

.toast {
  position: fixed;
  inset-inline: 0;
  bottom: 22px;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #182538;
  color: var(--text);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.bad {
  border-color: rgba(255, 107, 107, 0.45);
  background: #3a1b22;
}

.offscreen {
  position: fixed;
  inset-inline-start: -9999px;
  opacity: 0;
}

@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  form,
  .grid-2 {
    grid-template-columns: 1fr;
  }

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

  .auth-head {
    flex-direction: column;
  }

  .link-row {
    flex-wrap: wrap;
  }

  .link-row code {
    width: 100%;
    flex-basis: 100%;
    order: 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
