:root {
  color-scheme: dark;
  --background: #071522;
  --surface: #0d2233;
  --surface-soft: #112b3f;
  --border: rgba(161, 194, 218, 0.14);
  --primary: #2587d8;
  --active: #31d4bb;
  --warning: #e7ad49;
  --danger: #ef5b64;
  --text: #f4f8fb;
  --muted: #9fb2c2;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(37, 135, 216, 0.12), transparent 36%),
    var(--background);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 16px 104px;
}

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

.brand,
.label {
  margin: 0;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 3px 0 0;
  font-size: clamp(22px, 6vw, 32px);
  line-height: 1.05;
}

.subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.connection {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 112px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(13, 34, 51, 0.88);
}

.connection strong,
.connection small {
  display: block;
}

.connection strong {
  font-size: 11px;
}

.connection small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--warning);
  box-shadow: 0 0 14px currentColor;
}

.status-dot.online {
  background: var(--active);
}

.status-dot.offline {
  background: var(--danger);
}

.summary-card,
.info-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(
    145deg,
    rgba(17, 43, 63, 0.96),
    rgba(10, 29, 45, 0.96)
  );
  box-shadow: var(--shadow);
}

.summary-card {
  padding: 18px;
}

.summary-card > div:first-child strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.summary-grid article {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(5, 18, 29, 0.34);
}

.summary-grid span,
.control-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.summary-grid strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.control-card {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.control-card:active {
  transform: scale(0.985);
}

.control-card.active {
  border-color: rgba(49, 212, 187, 0.55);
  background: linear-gradient(
    135deg,
    rgba(49, 212, 187, 0.17),
    rgba(13, 34, 51, 0.98)
  );
}

.control-card.pending {
  border-color: rgba(231, 173, 73, 0.65);
}

.control-card:disabled {
  opacity: 0.55;
}

.control-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(37, 135, 216, 0.13);
  color: var(--primary);
  font-size: 24px;
}

.control-card.active .control-icon {
  background: rgba(49, 212, 187, 0.14);
  color: var(--active);
}

.control-card strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  letter-spacing: 0.03em;
}

.control-state {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.control-card.active .control-state {
  color: var(--active);
}

.stop-button {
  width: 100%;
  min-height: 58px;
  margin: 16px 0;
  border: 1px solid rgba(239, 91, 100, 0.42);
  border-radius: 17px;
  background: rgba(239, 91, 100, 0.12);
  color: #ff8d94;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.info-card {
  margin-top: 14px;
  padding: 17px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 4px 0 0;
  font-size: 17px;
}

.info-card p {
  margin: 16px 0 5px;
  font-size: 14px;
}

.info-card > small {
  color: var(--muted);
}

.stream-status {
  color: var(--warning);
  font-size: 11px;
}

.stream-status.connected {
  color: var(--active);
}

.technical-card dl {
  margin: 14px 0 0;
}

.technical-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.technical-card dl div:last-child {
  border-bottom: 0;
}

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

dd {
  margin: 0;
  text-align: right;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 92px;
  left: 16px;
  z-index: 20;
  max-width: 440px;
  margin: auto;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(9, 26, 40, 0.97);
  box-shadow: var(--shadow);
}

.toast strong,
.toast span {
  display: block;
}

.toast span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.toast.success {
  border-color: rgba(49, 212, 187, 0.5);
}

.toast.error {
  border-color: rgba(239, 91, 100, 0.55);
}

.hidden {
  display: none !important;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 72px;
  padding: 8px max(10px, env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  border-top: 1px solid var(--border);
  background: rgba(6, 20, 32, 0.96);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}

.bottom-nav button span {
  display: block;
  margin-bottom: 3px;
  font-size: 19px;
}

.bottom-nav button.active {
  color: var(--active);
}

@media (min-width: 720px) {
  .app-shell {
    padding: 28px 28px 110px;
  }

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

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

@media (min-width: 1024px) {
  .app-shell {
    padding-bottom: 36px;
  }

  main {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(310px, 0.55fr);
    gap: 18px;
  }

  .summary-card,
  .controls,
  .stop-button {
    grid-column: 1;
  }

  .info-card {
    grid-column: 2;
  }

  .technical-card {
    grid-row: 1 / span 2;
  }

  .bottom-nav {
    display: none;
  }
}