:root {
  --bg: #080a0c;
  --panel: #12161b;
  --panel-2: #181e25;
  --line: #27313b;
  --text: #f2f6f8;
  --muted: #97a4ad;
  --green: #51e640;
  --green-2: #26b937;
  --blue: #2f80ed;
  --danger: #ef4444;
  --radius: 8px;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at top left, rgba(81, 230, 64, 0.13), transparent 30%), var(--bg);
}

a {
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 420px;
  gap: 36px;
  align-items: center;
  padding: 48px;
}

.admin-page {
  min-height: 100vh;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 18px;
  padding: 34px 18px;
}

.admin-standalone {
  width: min(860px, 100%);
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.panel-separator {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.brand-block {
  max-width: 760px;
}

.brand-logo {
  display: block;
  width: min(680px, 100%);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.brand-subtitle {
  margin: 28px 0 0;
  font-size: 22px;
  color: var(--muted);
}

.login-panel,
.admin-panel {
  background: rgba(18, 22, 27, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.panel-head,
.dialog-head,
.topbar,
.watch-area,
.card-actions,
.quick-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

h1,
h2 {
  margin-bottom: 4px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0c1014;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(81, 230, 64, 0.16);
}

.server-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: -4px 0 16px;
}

.server-choice {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0d1217;
  color: var(--text);
  padding: 0 12px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-choice.active {
  border-color: var(--green);
  background: rgba(81, 230, 64, 0.12);
}

.primary,
.ghost,
.icon-btn,
.play-btn {
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 14px;
  color: var(--text);
}

.primary {
  width: 100%;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #071007;
  font-weight: 700;
}

.ghost,
.play-btn {
  background: #0d1217;
  border-color: var(--line);
}

.danger {
  border-color: rgba(239, 68, 68, 0.7);
  color: #fecaca;
}

.ghost:hover,
.play-btn:hover,
.icon-btn:hover,
.tab:hover {
  border-color: var(--green);
}

.icon-btn {
  width: 44px;
  padding: 0;
  background: #0d1217;
  border-color: var(--line);
  font-size: 22px;
}

.hint,
.message,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: var(--danger);
}

.player-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  background: #07090b;
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.side-logo {
  width: 100%;
  border-radius: var(--radius);
}

.main-tabs {
  display: grid;
  gap: 8px;
  align-content: start;
}

.tab {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 14px;
}

.tab.active {
  background: rgba(81, 230, 64, 0.12);
  border-color: rgba(81, 230, 64, 0.55);
  color: var(--text);
}

.tab.danger {
  border-color: rgba(239, 68, 68, 0.45);
  color: #fecaca;
}

.side-actions {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.content {
  min-width: 0;
  padding: 24px;
  max-width: 1180px;
  width: 100%;
  justify-self: center;
}

.topbar {
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.session-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 320px) minmax(160px, 240px) 44px;
  gap: 10px;
  align-items: center;
}

.watch-area {
  align-items: stretch;
  margin-bottom: 24px;
}

.video-frame {
  position: relative;
  flex: 1;
  min-height: 330px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.empty-player {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.58);
}

.now-playing {
  width: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
}

.quick-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.toggle-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.toggle-row input {
  width: 18px;
  min-height: 18px;
}

.pin-form {
  grid-template-columns: 1fr 1fr 150px;
}

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

.media-card {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.poster-button {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 0;
  padding: 0;
  background: #0a0d10;
}

.poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fallback-poster {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.poster[src=""],
.poster:not([src]) {
  display: none;
}

.poster[src=""] + .fallback-poster,
.poster:not([src]) + .fallback-poster {
  display: grid;
}

.card-body {
  padding: 12px;
}

.card-body h3 {
  min-height: 42px;
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.35;
}

.card-body p {
  min-height: 18px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-btn {
  width: 42px;
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #0d1217;
  color: var(--green);
}

.play-btn {
  flex: 1;
  min-height: 38px;
}

.admin-dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.admin-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.admin-content {
  display: grid;
  gap: 18px;
}

.admin-form {
  display: grid;
  grid-template-columns: 1fr 1.4fr 150px;
  gap: 12px;
  align-items: end;
}

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

.dns-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.dns-row strong {
  display: block;
  margin-bottom: 4px;
}

.dns-row span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .login-view,
  .player-view {
    grid-template-columns: 1fr;
  }

  .login-view {
    padding: 22px;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .tab {
    text-align: center;
    padding: 0 8px;
  }

  .side-actions {
    grid-template-columns: 1fr 1fr;
  }

  .topbar,
  .watch-area {
    align-items: stretch;
    flex-direction: column;
  }

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

  .session-actions {
    width: 100%;
    margin-left: 0;
  }

  .session-actions .ghost {
    flex: 1;
  }

  .now-playing {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 14px;
  }

  .main-tabs {
    grid-template-columns: 1fr 1fr;
  }

  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand-subtitle {
    font-size: 17px;
  }
}
